Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Allows python NaN values to be written as null in the JSON data #196

Closed
wants to merge 1 commit into from

Conversation

svernede
Copy link

JSON dump modified to allows python NaN values to be written as null in the JSON data

see #195

Adds a new dependency to module simplejson but the same effect is difficult to achieve with base module json
see http://stackoverflow.com/questions/28639953/python-nan-json-encoder

…ll` in the JSON data

see influxdata#195

Adds a new dependency to module   `simplejson` but the same effect is difficult to achieve with base module `json`
see http://stackoverflow.com/questions/28639953/python-nan-json-encoder
@aviau
Copy link
Collaborator

aviau commented Jun 15, 2015

I can see the improvement. However, I don't really like adding simplejson as a dependency. Are there any other solutions?

@svernede
Copy link
Author

Yes, I understand adding a new dependency is not desirable.
I could not find a way to achieve the result simply with the base json module.
Any suggestions are welcomed

@geodimm
Copy link
Contributor

geodimm commented Jun 16, 2015

Hi guys,

May I suggest an alternative solution to this problem? If the dataframe value is a list of floats, all NaN values in that list will be replaced with None thus making the numpy array object JSON compliant. The nice thing about this is that all of it happens before the serialization takes place. See one possible implementation here: 0feadd9. If you're not happy with it, we can make adjustments, but I think it's better not to play around with the JSON encoders.

Cheers!

@svernede
Copy link
Author

Looks good to me.
Thanks you Georgi for your kind help

On 17 June 2015 at 06:45, Georgi Dimitrov notifications@github.com wrote:

Hi guys,

May I suggest an alternative solution to this problem? If the dataframe
value is a list of floats, all NaN values in that list will be replaced
with None thus making the numpy array object JSON compliant. The nice thing
about this is that all of it happens before the serialization takes place.
See one possible implementation here: 0feadd9
0feadd9.
If you're happy with it, I'll make a pull request.

Cheers!


Reply to this email directly or view it on GitHub
#196 (comment)
.

@aviau
Copy link
Collaborator

aviau commented Jul 27, 2015

Closed in favor of #204

@aviau aviau closed this Jul 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants