[SERVER-2157] mongoexport fails with: 10311 Number nan cannot be represented in JSON Created: 29/Nov/10 Updated: 12/Jul/16 Resolved: 03/Dec/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | JavaScript, Tools |
| Affects Version/s: | None |
| Fix Version/s: | 2.1.0 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Matthew Rathbone | Assignee: | Brandon Diamond |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
osx, mongo_export, macbook pro |
||
| Issue Links: |
|
||||
| Participants: | |||||
| Description |
|
Exporting to JSON using mongoexport any record that contains a float which has value NaN will fail. Simple Example: { Additionally: When in the mongo console, you can exclude such records using: "slatlng" : {$ne [NaN, NaN]} but mongoexport cannot parse this as a valid json query. So you cannot do it. |
| Comments |
| Comment by auto [ 03/Dec/11 ] |
|
Author: {u'login': u'dwight', u'name': u'dwight', u'email': u'dwight@10gen.com'}Message: buildbot tojson NaN |
| Comment by auto [ 02/Dec/11 ] |
|
Author: {u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}Message: |
| Comment by auto [ 02/Dec/11 ] |
|
Author: {u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}Message: |
| Comment by Eliot Horowitz (Inactive) [ 30/Nov/10 ] |
|
Not really. I would recommend writing your own json exportor. Easy to do in any language. |
| Comment by Van Nguyen (vnguyen) [ 30/Nov/10 ] |
|
I'm getting the error but I'm not sure where the NaN is, it could be anywhere among the 200k documents and their subdocs. Is there a temp solution you could recommend for that situation? |
| Comment by Eliot Horowitz (Inactive) [ 30/Nov/10 ] |
|
Do you have NaN all over? If so - the type query probably won't work. |
| Comment by Van Nguyen (vnguyen) [ 30/Nov/10 ] |
|
is there an example of how to exclude $type:6 from every field and subfield? |
| Comment by Eliot Horowitz (Inactive) [ 30/Nov/10 ] |
|
Scott's suggestion should work temporarily. The other option is of course just writing your own json exporter. We'll need to figure out a long term solution. |
| Comment by Scott Hernandez (Inactive) [ 29/Nov/10 ] |
|
You should be able to exclude $type:6 (undefined) data. Or better yet, just export $type:1 (double). |
| Comment by Matthew Rathbone [ 29/Nov/10 ] |
|
Ok, so to elaborate a little more: We're storing values with NaN for some reason (probably stored by the ORM we're using). Ideally I'd like mongoexport to succeed and replace the NaN with something else (undefined, null, false, "NaN", anything really). Maybe it should even skip the record. My real problem is that it causes mongoexport to crash and stop exporting. |