use of org.bson.codecs.IterableCodec in project LanternPowerMonitor by MarkBryanMilligan.
the class DaoSerializer method parseList.
public static List<DaoEntity> parseList(String _json) {
try {
List<DaoEntity> entities = new ArrayList<>();
JsonReader bsonReader = new JsonReader(_json);
for (Object o : new IterableCodec(CodecRegistries.fromProviders(Arrays.asList(new ValueCodecProvider(), new BsonValueCodecProvider(), new DocumentCodecProvider())), new BsonTypeClassMap()).decode(bsonReader, DecoderContext.builder().build())) {
if (o instanceof Document)
entities.add(new DaoEntity((Document) o));
}
return entities;
} catch (Exception _e) {
LOG.error("Failed to parse json", _e);
return null;
}
}
Aggregations