Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2433

JsonReader module chokes on int $type for binary extended json

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.0
    • Affects Version/s: 3.0.0
    • Component/s: JSON
    • None
    • Fully Compatible

      There are two extended json parsers in the mongo-java-driver project. One in the driver module, one in the bson module. The one in the driver itself only supports the $type field of the binary extended json representation to be an integer. There is an unreleased patch in master that also allows the hex representation:

      https://github.com/mongodb/mongo-java-driver/commit/600a37703ed6b4ad41bfab969a8efcbd51a00c6e#diff-71878e8b11c0d2fd1c3df294dc915e31

      The JsonReader parser in the bson module however ONLY supports the hex representation as can be seen in https://github.com/mongodb/mongo-java-driver/blob/c610f1853a4a3e9e5762e196adb076b647f418ac/bson/src/main/org/bson/json/JsonReader.java#L903

      This means those to parsers are currently incompatible in their released forms. You can't create an extended json representation that works with both.

      The com.mongodb.util.JSON parser chokes on

      { "$binary": "YWzDtmhh", "$type": "0" }
      

      (until the next release).

      The JsonReader parser in the bson module chokes on

      { "$binary": "YWzDtmhh", "$type": 0 }.
      

      The JsonReader parser should be fixed to also support the int representation.

      We are using both mongo-scala-driver and mongo-java-driver in our project, so we currently have a problem with this.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            chris.vogt@human.x.ai Chris Vogt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: