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

Add JsonEncoder and JsonDecoder implementations to their Bson counterparts

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Unknown Unknown
    • None
    • None
    • Kotlin

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: