use of org.whole.lang.json.util.JSONParserTemplateFactory in project whole by wholeplatform.
the class JSONLDPersistenceKit method doReadModel.
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
JsonFactory factory = new JsonFactory();
JsonParser parser = factory.createParser(pp.getInputStream());
parser.disable(Feature.AUTO_CLOSE_SOURCE);
try {
return new JSONLDEntityDecoder().clone(new JSONParserTemplateFactory(parser).create());
} finally {
parser.close();
}
}
use of org.whole.lang.json.util.JSONParserTemplateFactory in project whole by wholeplatform.
the class JSONSourcePersistenceKit method doReadModel.
protected IEntity doReadModel(IPersistenceProvider pp) throws Exception {
JsonFactory factory = new JsonFactory();
// factory.enable(JsonParser.Feature.ALLOW_COMMENTS);
JsonParser parser = factory.createParser(pp.getInputStream());
parser.disable(Feature.AUTO_CLOSE_SOURCE);
try {
return new JSONParserTemplateFactory(parser).create();
} finally {
parser.close();
}
}
use of org.whole.lang.json.util.JSONParserTemplateFactory in project whole by wholeplatform.
the class JSONPersistencesTest method testStreamAndBuildParserEquivalence.
@Test
public void testStreamAndBuildParserEquivalence() throws Exception {
IEntity sampleModelByFactory = JSONSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getClass().getResourceAsStream("sample.json")));
ModelBuilderOperation op = new ModelBuilderOperation();
new JSONParserTemplateFactory(new JsonFactory().createParser(sampleString)).apply(op);
IEntity sampleModelByBuilder = ReflectionFactory.makeRootEntity(op.wGetResult());
assertTrue(Matcher.match(sampleModelByFactory, sampleModelByBuilder));
}
Aggregations