… And, since 3.0.0, you can:
import org.bson.Document;
final Document doc = new Document("myKey", "myValue");
final String jsonString = doc.toJson();
final Document doc = Document.parse(jsonString);
Official docs:
Related Contents:
- Jackson with JSON: Unrecognized field, not marked as ignorable
- Ignoring new fields on JSON objects using Jackson [duplicate]
- How to convert jsonString to JSONObject in Java
- Gson: How to exclude specific fields from Serialization without annotations
- Serializing with Jackson (JSON) – getting “No serializer found”?
- Converting JSON data to Java object
- Simplest way to read JSON from a URL in Java
- Testing two JSON objects for equality ignoring child order in Java [closed]
- How to check if a JSON key exists?
- Quickest way to convert XML to JSON in Java [closed]
- Jackson: how to prevent field serialization [duplicate]
- Convert object to JSON in Android
- How to fluently build JSON in Java? [closed]
- Android JSONObject – How can I loop through a flat JSON object to get each key and value
- Get ID of last inserted document in a mongoDB w/ Java driver
- How to parse JSON Array (Not Json Object) in Android
- Android Json and null values
- Serializing enums with Jackson
- Trying to use Spring Boot REST to Read JSON String from POST
- Keep the order of the JSON keys during JSON conversion to CSV
- Spring JSON request getting 406 (not Acceptable)
- Deserializing an enum with Jackson
- Error 415 Unsupported Media Type: POST not reaching REST if JSON, but it does if XML
- Convert JsonNode object to Map
- Spring MVC controller Test – print the result JSON String
- Unit testing with MongoDB
- How to deserialize JS date using Jackson?
- GSON – Get JSON value from String
- Trouble with Gson serializing an ArrayList of POJO’s
- How to serialize Object to JSON?
- Can not find a (Map) Key deserializer for type [simple type, class …]
- Strange Jackson exception being thrown when serializing Hibernate object
- Not-null property references a transient value – transient instance must be saved before current operation
- How to parse a dynamic JSON key in a Nested JSON result?
- Creating GSON Object
- how to show query while using query annotations with MongoRepository with spring data
- Is default no-args constructor mandatory for Gson?
- How to find specified name and its value in JSON-string from Java?
- How to map JSON field names to different object field names?
- Want to hide some fields of an object that are being mapped to JSON by Jackson
- How to parse a JSON Input stream
- Faster XML Jackson: Remove double quotes
- Custom JSON Deserialization with Jackson
- How to test if a JSONObject is null or doesn’t exist
- Get single field from JSON using Jackson
- Query a JSONObject in java
- Jackson JSON library: how to instantiate a class that contains abstract fields
- Jackson read value as string
- How to Validate JSON with Jackson JSON
- Deserializing an abstract class in Gson