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?

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

3 Comments

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...
Since BSON was written by 10gen and JSON by a different source, I do not know of any common implementation.
-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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.