Create a Document from a JSON String in Java OJAI
You can create a new JSON document in your Java OJAI client by passing a JSON string to
the Connection.newDocument()
method.
To create the following JSON document:
{ "_id":"id001", "a":1, "b":"aString", "array":[ 1, 2, "arrStr", { "c":"arrMapStr" } ] }
Call Connection.newDocument()
, passing in a JSON string with
escaped quotes:
Document pojoDoc = connection.newDocument( "{\"_id":\"id001\",\"a\":1,\"b\":\"aString\",\"array\":[1,2,\"arrStr\",{\"c\":\"arrMapStr\"}]}");