Creating BSON object from JSON string

前端 未结 9 1663
眼角桃花
眼角桃花 2020-12-01 03:10

I have Java app that takes data from external app. Incoming JSONs are in Strings. I would like to parse that Strings and create BSON objects.

Unfortunate I can\'t fi

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 04:04

    You'll find the answer to your question in the source code of https://github.com/mongodb/mongo/blob/master/src/mongo/db/jsobj.cpp Which has the BSON to JSON conversion.

    Basically, stuff like

    • ObjectId("XXX") -> { "$oid" : "XXX" }
    • /XXX/gi -> { "$regex" : "XXX", "$options" : "gi" }

    and so on...

提交回复
热议问题