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

ObjectId is not supported by class kotlinx.serialization.json.internal.StreamingJsonEncoder

    • Type: Icon: Question Question
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      Servers like ktor is using StreamingJsonEncoder for the responses internaly but MongoDB ObjectId does not support StreamingJsonEncoder for the ...

      kotlinx.serialization.SerializationException: ObjectId is not supported by class kotlinx.serialization.json.internal.StreamingJsonEncoder
      	at org.bson.codecs.kotlinx.ObjectIdSerializer.serialize(BsonSerializers.kt:74) ~[bson-kotlinx-4.10.1.jar:?]
      	at org.bson.codecs.kotlinx.ObjectIdSerializer.serialize(BsonSerializers.kt:66) ~[bson-kotlinx-4.10.1.jar:?]
      	at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:228) ~[kotlinx-serialization-json-jvm-1.5.0.jar:?]
      	at kotlinx.serialization.ContextualSerializer.serialize(ContextualSerializer.kt:63) ~[kotlinx-serialization-core-jvm-1.5.0.jar:1.5.0]
      	at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:228) ~[kotlinx-serialization-json-jvm-1.5.0.jar:?]
      

      How to Reproduce

      When you want to send ObjectId value in the response of ktor server...
      https://ktor.io/
      (I'm tired and I didn't sleep for days dealing with MongoDb issues... please help the brother out)

            Assignee:
            Unassigned Unassigned
            Reporter:
            jar.fmf@gmail.com Uroš Jarc
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: