5

I'm using the native MongoDB driver and API, which uses com.mongodb.DBObject to represent JSON objects, however for general purpose I have usage of org.json.JSONOBject.

I thought of replacing it and using DBObject as a general JSON library, but it doesn't feel right.

But to interop with the two, the low level String/Map format/parse interface is used, which I don't like either.

Is there a known library out there that implements both interfaces for easier interoperability?

Eran Medan
  • 44,555
  • 61
  • 184
  • 276

1 Answers1

1

In general, converting between BSON and JSON was intended to be a painless operation, so you shouldn't have to write more classes. Does this answer help at all?

Community
  • 1
  • 1
shelman
  • 2,689
  • 15
  • 17
  • Yes, a little, but I can't help but wonder if there isn't something like the `org.w3c.Node` as a common interface for all JSON implementations. Maybe something in Scala... – Eran Medan Oct 11 '12 at 18:09
  • Since BSON was written by 10gen and JSON by a different source, I do not know of any common implementation. – shelman Oct 12 '12 at 15:54
  • -1 for a bad answer that links to a bad answer that links to an answer that isn't relevant here. What you're really saying is: convert the org.json object into a json string then parse it back as a DBObject. That's not what OP is asking for. – James Watkins Jan 23 '16 at 21:27