Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file output format from dict repr to json.dumps #3

Merged
merged 1 commit into from
Aug 2, 2019

Conversation

prog893
Copy link
Member

@prog893 prog893 commented Aug 2, 2019

str() method converts dict to string with dict representation (__repr__), which is not valid JSON, but valid Python code.

Since we only care about JSON logs anyways, this PR fixes string conversion with json.dumps.

@prog893 prog893 requested a review from toVersus August 2, 2019 03:11
Copy link
Contributor

@toVersus toVersus left a comment

Choose a reason for hiding this comment

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

Ah, gotcha. LGTM

>>> dict = {"name": "john"}
>>> type(dict)
<class 'dict'>
>>> str(dict)
"{'name': 'john'}" # invalid json format
>>> json.dumps(dict)
'{"name": "john"}' # valid json format 

@prog893 prog893 merged commit 108ae0f into master Aug 2, 2019
@prog893 prog893 deleted the fix-output-format branch August 2, 2019 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants