[JAVA-521] JSON parser parses longs as ints Created: 14/Feb/12  Updated: 18/Jun/12  Resolved: 14/Feb/12

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.6.5, 2.7.3
Fix Version/s: 2.8.0

Type: Bug Priority: Minor - P4
Reporter: John R Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by JAVA-399 bad bson decode/encode Closed

 Description   

The JSON parser parses longs as ints, as in the example below. I have only checked java driver versions 2.6.5 and 2.7.3.

BasicDBObject test = new BasicDBObject();
test.put("num", new Long(-5312343143242334L));
System.out.println(JSON.serialize(test)); // ok

{ "num" : -5312343143242334}

System.out.println(JSON.parse(JSON.serialize(test))); // error

{ "num" : -1174035038}

 Comments   
Comment by Jeffrey Yemin [ 18/Jun/12 ]

Closing for 2.8.0 release.

Comment by auto [ 14/Feb/12 ]

Author:

{u'login': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-521: JSON.parse doesn't handle longs less than INTEGER.MAX_VALUE correctly
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/408b3564fc7d0cf29c503c26632ff3e0eebd6110

Generated at Thu Feb 08 08:52:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.