[JAVA-2905] JsonReader doesn't parse DBPointer in strict representation correctly Created: 11/Jul/18  Updated: 11/Feb/19  Resolved: 11/Feb/19

Status: Closed
Project: Java Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: jin Assignee: Ross Lawley
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File TestDBPointer.java    

 Description   

Hi Experts,

I am using JsonReader in Bson lib to parse the JSON in strict representation, but it looks like the DBPointer type is not correctly parsed, it parsed as DOCUMENT type.

Attachment is a simple test program to reproduce this problem, can you please look at it and suggest me? Thank you very much!

BTW. I am using bson-3.8.0.jar in the test.

Regards,

Jin



 Comments   
Comment by Jeffrey Yemin [ 26/Dec/18 ]

Hi zhao. I agree it's low priority. I have never heard of a DBPointer actually used by anyone.

To answer your questions:

  1. Extended JSON is the recommended way to interoperate with JSON in drivers, as it is able to preserve all BSON type information.
  2. MongoDB currently doesn't provide a command-line tool that imports/exports in extended JSON, but please follow TOOLS-1610 to track the work that we're doing to enable that. Meanwhile, it's easy to write your own using any of the supported MongoDB drivers, including the Java driver.
  3. The specification is here: https://github.com/mongodb/specifications/blob/master/source/extended-json.rst
Comment by jin [ 20/Dec/18 ]

Hi Ross,

Sorry for my late response.

What I am doing to try parse JSON output from mongoexport which is in strict mode to be used by our application, since we want to make it as general utility, so that we try to cover all supported types, that why BsonDbPointer type is included. If BsonDbPointer was deprecated for many years, maybe this problem is really low priority and probably can be ignored. 

I have questions for EXTEDNED JSON representation:

  • Is it recommended JSON representation in MongoDB?
  • Which tool can be used to dump data from MongoDB to EXTENDED JSON mode, it looks like mongoexport always dump to STRICT mode JSON.
  • Where can I find the spec of EXTENDED JSON representation? The document https://docs.mongodb.com/manual/reference/mongodb-extended-json/ describes STRICT mode and SHELL mode but not for EXTENDED mode

Thank you so much!

Jin

Comment by Ross Lawley [ 13/Dec/18 ]

Hi zhao,

Apologies for the lack of feedback on this ticket. I have been working on a fix but before I commit it, I'd like to understand a little more about your usecase specifically:

  • Why use the STRICT over the EXTENDED Json representation? STRICT is now deprecated.
  • Why use BsonDbPointer - the Bson DBPointer type was deprecated many years ago.

The reasons for the questions are due to the fix. It would change how a BsonDbPointer is encoded into json, so that it matches the EXTENDED spec rather than following the DBRef convention.

Many thanks,

Ross
 

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