JsonStackingSemanticTranslator extends AbstractStackingSemanticTranslator<JsonStackItem> implements StackingSemanticTranslator<JsonStackItem> { @Override public Model translate(InputStream dataStream, String entityIdentifier, ExtractedOntology managedOntology) throws SemanticTranslationException { final Model result = modelFactory.createModel(); try (final JsonParser jsonParser = JSON_FACTORY.createParser(dataStream)) { JsonToken token = null; while ((token = jsonParser.nextToken()) != null) { parseToken(result, managedOntology, token, jsonParser); } } catch (JsonParseException e) { throw new SemanticTranslationException("Issue parsing JSON from incoming data, on entity: " + entityIdentifier, e); } catch (IOException e) { throw new SemanticTranslationException("Issue reading incoming stream to extract meaning from " + entityIdentifier, e); } return result; } JsonStackingSemanticTranslator(); @Reference void setValueFactory(ValueFactory valueFactory); @Reference void setModelFactory(ModelFactory modelFactory); @Reference void setExpressionProcessor(IriExpressionProcessor expressionProcessor); @Reference void setOrmFactoryRegistry(OrmFactoryRegistry ormFactoryRegistry); @Override Model translate(InputStream dataStream, String entityIdentifier, ExtractedOntology managedOntology);  }
@Test public void basicTest() throws Exception { final Model output = this.extractor.translate(Paths.get("src/test/resources/test.json"), this.ontology); this.ontology.getModel().forEach(System.out::println); System.out.println("\n\n\n"); output.forEach(System.out::println); Assert.assertNotNull(output); Assert.assertFalse(output.isEmpty()); Assert.assertEquals(8, getRequiredOrmFactory(ExtractedDatatypeProperty.class).getAllExisting(ontology.getModel()).size()); Assert.assertEquals(4, getRequiredOrmFactory(ExtractedObjectProperty.class).getAllExisting(ontology.getModel()).size()); }
@Test public void twoDimensionalArraysTest() throws Exception { final Model output = this.extractor.translate( Paths.get("src/test/resources/test2dArrays.json"), this.ontology); Assert.assertNotNull(output); Assert.assertFalse(output.isEmpty()); }