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

Add parse factory method to BsonArray

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.4.0-rc1, 3.4.0
    • Affects Version/s: None
    • Component/s: JSON
    • None

      It would be handy if JSON parsing facilities in the Java driver existed that used compatible types with the collection/database methods that take BSON parameters.

      Notably, parsing a JSON string to pass to the "aggregate" method requires some fiddling to bring the two APIs into alignment. This same condition arises in a few other places wherever something other than BsonDocument is required.

      To go from a JSON string to something which can be passed to the aggregate method, for example, requires this rather unwieldy extra step:

      BsonArray array = new BsonArrayCodec(MongoClient.getDefaultCodecRegistry())
              .decode(new JsonReader(myJsonString), DecoderContext.builder().build());
      

      This ticket is to request the implementation of some intuitive utility methods to bridge the gap. Perhaps directly in the JSON class.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            andrew.ryder@mongodb.com Andrew Ryder (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: