[CDRIVER-1938] bson_as_json converts int64 to scientific notation Created: 28/Nov/16 Updated: 11/Sep/19 Resolved: 28/Feb/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | json, libbson |
| Affects Version/s: | 1.3.5 |
| Fix Version/s: | 1.7.0 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Darin Christenson | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux |
||
| Epic Link: | libbson corpus |
| Description |
|
When trying to retrieve an int64 value using mongoc_collection_find, mongoc_cursor_next, and bson_as_json, I need to see the full value. When I run the code now, it translates my value into scientific notation, which loses precision (e.g., 1479421652125003000 becomes 1.479421652125e+18). Is there any way to get the actual value instead of the scientific notation value? |
| Comments |
| Comment by Githook User [ 24/Feb/17 ] |
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: Fixes |
| Comment by A. Jesse Jiryu Davis [ 28/Nov/16 ] |
|
Hi Darin. Currently, no, there's no way to make bson_as_json produce exact output. We've discussed this in Meanwhile, you can certainly read the exact value in C with bson_iter_as_int64, but you'll need to convert the result to a string yourself in order to preserve precision. |