use of org.immutables.mongo.bson4gson.BsonReader in project immutables by immutables.
the class Jsons method asGsonReader.
static JsonReader asGsonReader(BsonDocument bson) {
BasicOutputBuffer output = new BasicOutputBuffer();
new BsonDocumentCodec().encode(new BsonBinaryWriter(output), bson, EncoderContext.builder().build());
return new BsonReader(new BsonBinaryReader(ByteBuffer.wrap(output.toByteArray())));
}
use of org.immutables.mongo.bson4gson.BsonReader in project immutables by immutables.
the class Jsons method readerAt.
/**
* Creates reader for position at {@code value}
*/
static JsonReader readerAt(BsonValue value) throws IOException {
BsonDocument doc = new BsonDocument("value", value);
BsonReader reader = new BsonReader(new BsonDocumentReader(doc));
// advance AFTER value token
reader.beginObject();
check(reader.peek()).is(JsonToken.NAME);
check(reader.nextName()).is("value");
return reader;
}
Aggregations