Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions loklak.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def xmlToJson(self, xmlData = None):

def csvToJson(self, csvData = None, fieldnamesList = None):
"""Convert CSV to JSON as the service."""
jsonData = ''
jsonData = '[]'
if csvData:
data = csv.DictReader( csvData, fieldnames = fieldnamesList)
jsonData = json.dumps( [ row for row in data ] )
return out
return jsonData

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the code doesn't enter the csvData if block, it ends up returning '' which is not a valid json. if the JSON is what needs to be returned then ideally it should return {}

@YJDave YJDave Jan 25, 2018

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then that should be applied to xmlToJson method too.
This method not at all gives expected output json. Should I change the whole definition of this method?(which can generate right json data from csv)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely! Thanks for catching that. Feel free to make a change to that too. 😄


def hello(self):
"""Retrieve a json response about the basic status of the server."""
Expand Down