use of com.mongodb.LazyDBCallback in project immutables by immutables.
the class BsonEncoding method unwrapJsonable.
public static DBObject unwrapJsonable(String json) {
try {
JsonParser parser = JSON_FACTORY.createParser(json);
parser.nextToken();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BsonGenerator generator = BSON_FACTORY.createGenerator(outputStream);
generator.copyCurrentStructure(parser);
generator.close();
parser.close();
byte[] data = outputStream.toByteArray();
return (DBObject) new LazyDBCallback(null).createObject(data, 0);
} catch (IOException ex) {
throw Throwables.propagate(ex);
}
}
Aggregations