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

Add JsonEncoder and JsonDecoder implementations to their Bson counterparts

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 5.2.0
    • Affects Version/s: None
    • Component/s: Kotlin
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?

      Just a note mentioning that JsonElement values are supported if kotlinx-serialization-json is available on the class path.

      2. Would you like the user to see examples of the syntax and/or executable code and its output?

      n/a

      3. Which versions of the driver/connector does this apply to?

      5.2.0

      Show
      1. What would you like to communicate to the user about this feature? Just a note mentioning that JsonElement values are supported if kotlinx-serialization-json is available on the class path. 2. Would you like the user to see examples of the syntax and/or executable code and its output? n/a 3. Which versions of the driver/connector does this apply to? 5.2.0

      Kotlinx requires the encoder to implement JsonEncoder and JsonDecoder in order to encode generic JsonElement types.

      The lack of this support for this came up many times when using KBson and KMongo previously and I'm hoping we can quickly mitigate this now that MongoDB has official support.

      I've added each implementation to support most types on decoding and determine the best possible type on encoding to insert. It is somewhat assumed that if someone is encoding a JsonElement, then they will probably be decoding one as well and, therefore, type information is primarily for storage optimization.

      Unfortunately, Kotlinx writes all numbers as 64 bit integers first and never attempts to check for 32 bits or allow overriding the JsonElementSerializer behavior; this means that all integers will probably be written as int64. Regardless, this should be a valuable add.

      PR: https://github.com/mongodb/mongo-java-driver/pull/1253

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            ross@mongodb.com Ross Lawley
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: