[CDRIVER-994] "[{$numberLong: '1'}]" is BSON-encoded with array key name "1" Created: 12/Nov/15  Updated: 10/Jul/17  Resolved: 10/Dec/16

Status: Closed
Project: C Driver
Component/s: json, libbson
Affects Version/s: None
Fix Version/s: 1.6.0

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File CDRIVER-994-tests.patch    
Issue Links:
Depends
depends on CDRIVER-1370 Replace libyajl with jsonsl Closed
is depended on by PHPC-974 Converting JSON to BSON to PHP introd... Closed

 Description   

bson_init_from_json with this input:

"[ { \"$numberLong\" : \"123\" },  { \"$numberLong\" : \"42\" } ]"

... encodes an array with keys "1", "3", instead of the expected "0", "1".

Something on the parser stack isn't popped after finishing a parse of an extended-JSON map like {$numberLong: "123"}, and array keys are incremented twice between BSON elements.



 Comments   
Comment by Githook User [ 10/Jul/17 ]

Author:

{u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}

Message: PHPC-974: Regression test for array index gaps in JSON->BSON->PHP

Fixed in libbson 1.6.0 by CDRIVER-994.
Branch: master
https://github.com/mongodb/mongo-php-driver/commit/c8657acbe068033b56dec93fe7c041f685a95b69

Comment by Githook User [ 10/Dec/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-994 fix array keys of special JSON types

The BSON array keys produced from parsing JSON like this:

[{$numberLong: "123"}, {$numberLong: "456"}]

Had been "1", "3" instead of the correct "0", "1".
Branch: master
https://github.com/mongodb/libbson/commit/416aa5f498d25f876aff526c3fad96e15f9141f3

Comment by Githook User [ 09/Feb/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-994 ignore keys in array-matching tests
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/ef415279593a40337fa42b2f916b89f13562bc57

Comment by A. Jesse Jiryu Davis [ 13/Nov/15 ]

Once fixed, update _test_kill_cursors to use match_json like other mock server tests do.

Comment by A. Jesse Jiryu Davis [ 12/Nov/15 ]

Reproduction.

Generated at Wed Feb 07 21:11:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.