@Test public void performSerialization() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); JsonLdSerialization cs = new JsonLdSerialization(out); cs.serialize(SourceData.simpleResult()); assertThat(out.toString(), is("{\n" + " \"data\" : {\n" + " \"Persons\" : {\n" + " \"items\" : [ {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"a\" : {\n" + " \"type\" : \"http: " \"value\" : \"1\"\n" + " },\n" + " \"b\" : {\n" + " \"prevCursor\" : \"next\",\n" + " \"items\" : [ {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"c\" : {\n" + " \"type\" : \"http: " \"value\" : \"2\"\n" + " },\n" + " \"d\" : {\n" + " \"items\" : [ {\n" + " \"type\" : \"http: " \"value\" : \"3\"\n" + " }, {\n" + " \"type\" : \"http: " \"value\" : \"4\"\n" + " }, null ]\n" + " }\n" + " }, {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"c\" : {\n" + " \"type\" : \"http: " \"value\" : \"5\"\n" + " },\n" + " \"d\" : {\n" + " \"items\" : [ {\n" + " \"type\" : \"http: " \"value\" : \"6\"\n" + " }, {\n" + " \"type\" : \"http: " \"value\" : \"7\"\n" + " } ]\n" + " }\n" + " } ]\n" + " }\n" + " }, {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"a\" : {\n" + " \"type\" : \"http: " \"value\" : \"8\"\n" + " },\n" + " \"b\" : {\n" + " \"items\" : [ {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"c\" : {\n" + " \"type\" : \"http: " \"value\" : \"9\"\n" + " },\n" + " \"d\" : {\n" + " \"items\" : [ {\n" + " \"type\" : \"http: " \"value\" : \"10\"\n" + " }, {\n" + " \"type\" : \"http: " \"value\" : \"11\"\n" + " } ]\n" + " }\n" + " }, {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"c\" : {\n" + " \"type\" : \"http: " \"value\" : \"12\"\n" + " },\n" + " \"d\" : {\n" + " \"items\" : [ {\n" + " \"type\" : \"http: " \"value\" : \"13.0\"\n" + " }, {\n" + " \"type\" : \"http: " \"value\" : \"14\"\n" + " } ]\n" + " }\n" + " }, {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"c\" : {\n" + " \"type\" : \"http: " \"value\" : \"15\"\n" + " },\n" + " \"d\" : {\n" + " \"items\" : [ {\n" + " \"type\" : \"http: " \"value\" : \"16\"\n" + " }, {\n" + " \"type\" : \"http: " \"value\" : \"17\"\n" + " }, {\n" + " \"type\" : \"http: " \"value\" : \"18\"\n" + " } ]\n" + " }\n" + " } ]\n" + " }\n" + " }, {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"a\" : {\n" + " \"type\" : \"http: " \"value\" : \"19\"\n" + " },\n" + " \"b\" : {\n" + " \"@id\" : \"http: " \"@type\" : \"http: " \"e\" : {\n" + " \"type\" : \"http: " \"value\" : \"20\"\n" + " },\n" + " \"f\" : {\n" + " \"type\" : \"http: " \"value\" : \"21\"\n" + " }\n" + " }\n" + " } ]\n" + " }\n" + " },\n" + " \"@context\" : {\n" + " \"data\" : {\n" + " \"@id\" : \"@graph\",\n" + " \"@container\" : \"@index\"\n" + " },\n" + " \"value\" : \"@value\",\n" + " \"type\" : \"@type\",\n" + " \"a\" : \"http: " \"b\" : {\n" + " \"@reverse\" : \"http: " },\n" + " \"c\" : \"http: " \"d\" : \"http: " \"a\" : \"http: " \"b\" : \"http: " \"e\" : \"http: " \"f\" : \"http: " }\n" + "}")); }
@Override public void serialize(SerializableResult serializableResult) throws IOException { final Set<PredicateInfo> context = new LinkedHashSet<>(); generator.writeStartObject(); generator.writeFieldName("data"); generator.writeStartObject(); for (Map.Entry<String, Serializable> entry : serializableResult.getData().getContents().entrySet()) { generator.writeFieldName(entry.getKey()); dispatcher.dispatch(entry.getValue(), context); } generator.writeEndObject(); writeContext(context); generator.writeEndObject(); generator.flush(); generator.close(); }
JsonLdSerialization implements Serialization { @Override public void serialize(SerializableResult serializableResult) throws IOException { final Set<PredicateInfo> context = new LinkedHashSet<>(); generator.writeStartObject(); generator.writeFieldName("data"); generator.writeStartObject(); for (Map.Entry<String, Serializable> entry : serializableResult.getData().getContents().entrySet()) { generator.writeFieldName(entry.getKey()); dispatcher.dispatch(entry.getValue(), context); } generator.writeEndObject(); writeContext(context); generator.writeEndObject(); generator.flush(); generator.close(); } }
JsonLdSerialization implements Serialization { @Override public void serialize(SerializableResult serializableResult) throws IOException { final Set<PredicateInfo> context = new LinkedHashSet<>(); generator.writeStartObject(); generator.writeFieldName("data"); generator.writeStartObject(); for (Map.Entry<String, Serializable> entry : serializableResult.getData().getContents().entrySet()) { generator.writeFieldName(entry.getKey()); dispatcher.dispatch(entry.getValue(), context); } generator.writeEndObject(); writeContext(context); generator.writeEndObject(); generator.flush(); generator.close(); } JsonLdSerialization(OutputStream outputStream); }
JsonLdSerialization implements Serialization { @Override public void serialize(SerializableResult serializableResult) throws IOException { final Set<PredicateInfo> context = new LinkedHashSet<>(); generator.writeStartObject(); generator.writeFieldName("data"); generator.writeStartObject(); for (Map.Entry<String, Serializable> entry : serializableResult.getData().getContents().entrySet()) { generator.writeFieldName(entry.getKey()); dispatcher.dispatch(entry.getValue(), context); } generator.writeEndObject(); writeContext(context); generator.writeEndObject(); generator.flush(); generator.close(); } JsonLdSerialization(OutputStream outputStream); @Override void serialize(SerializableResult serializableResult); }
JsonLdSerialization implements Serialization { @Override public void serialize(SerializableResult serializableResult) throws IOException { final Set<PredicateInfo> context = new LinkedHashSet<>(); generator.writeStartObject(); generator.writeFieldName("data"); generator.writeStartObject(); for (Map.Entry<String, Serializable> entry : serializableResult.getData().getContents().entrySet()) { generator.writeFieldName(entry.getKey()); dispatcher.dispatch(entry.getValue(), context); } generator.writeEndObject(); writeContext(context); generator.writeEndObject(); generator.flush(); generator.close(); } JsonLdSerialization(OutputStream outputStream); @Override void serialize(SerializableResult serializableResult);  }