[SERVER-11136] Support json parsing of NumberLong/Int Created: 11/Oct/13  Updated: 11/Jul/16  Resolved: 11/Oct/13

Status: Closed
Project: Core Server
Component/s: Internal Code, Tools
Affects Version/s: None
Fix Version/s: 2.5.3

Type: Improvement Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-6812 Extended JSON syntax should support a... Closed
Related
related to SERVER-11135 BSONObjBuilder.appendNumber(numeric_l... Closed
related to SERVER-11867 In strict-json mode, represent Number... Closed
Backwards Compatibility: Fully Compatible
Participants:

 Comments   
Comment by Scott Hernandez (Inactive) [ 04/Dec/13 ]

The goal of this work was not to roundtrip values/types, but simply to improve the parser for internal use. You will want to follow SERVER-6812 for that other discussion.

However I think there is a bug and this format is TenGen not JS (extended) as is here: https://github.com/mongodb/mongo/blob/b7434b66409c8d4515b94d3d7e647cf68b2c46ec/src/mongo/db/jsobj.cpp#L81 – I will add that note to the other work being done here: SERVER-11867

Comment by Antoine Girbal [ 04/Dec/13 ]

scotthernandez
if I understand this ticket, we added a way to serialize numberlong / numberint in JSON so that they are roundtripped properly.
From commit it seems we are using the shell notation like "NumberLong()" which is not proper JSON.
Instead we should properly pick a notation that is real JSON and make it part of the JSON extended spec.
http://docs.mongodb.org/manual/reference/mongodb-extended-json/

It seems quite important that our import / export method like mongoimport has the ability to keep a given number type.
The shell tries to keep the same type if a document gets updated, I believe.
Current caveats:

  • the JSON parser as-is may insert a mix of Int, Long and Double depending on the value seen.
  • application could break if it's expecting a specific type and it's getting a mix of them.
  • what is displayed in the shell could surprise the user.
  • updates that are supposed to be fast in-place could instead grow document and trigger migration.
Comment by auto [ 12/Nov/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-11136 SERVER-11135 support NumberLong() in BSONElement::jsonString() result
Branch: master
https://github.com/mongodb/mongo/commit/b7434b66409c8d4515b94d3d7e647cf68b2c46ec

Comment by auto [ 11/Oct/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-11136: add explicit cast
Branch: master
https://github.com/mongodb/mongo/commit/cc3c80cb841f35f2ef315d6db0eba9e9c3ddc46c

Comment by auto [ 11/Oct/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-11136 - Support json parsing of NumberLong/Int
Branch: master
https://github.com/mongodb/mongo/commit/b2bda16ef3c0ad75b0ee63bac65842d4de513470

Generated at Thu Feb 08 03:25:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.