@Test public void testSerializeData() throws Exception { Writer serializeData = bindingSerializer.serializeData(schemaContext, testedToasterNormalizedNodes); Assert.assertFalse(Strings.isNullOrEmpty(serializeData.toString())); LOG.info(serializeData.toString()); }
@Override public Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(writer); JSONCodecFactory jsonCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.createLazy(this.schemaContext); URI namespace = schemaNode.getQName().getNamespace(); NormalizedNodeStreamWriter create = JSONNormalizedNodeStreamWriter.createExclusiveWriter(jsonCodecFactory, schemaNode.getPath(), namespace, jsonWriter); try (NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(create)) { normalizedNodeWriter.write(normalizedNode); jsonWriter.flush(); } catch (IOException ioe) { throw new SerializationException(ioe); } return writer; }
JsonNodeConverter implements NodeConverter { @Override public Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(writer); JSONCodecFactory jsonCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.createLazy(this.schemaContext); URI namespace = schemaNode.getQName().getNamespace(); NormalizedNodeStreamWriter create = JSONNormalizedNodeStreamWriter.createExclusiveWriter(jsonCodecFactory, schemaNode.getPath(), namespace, jsonWriter); try (NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(create)) { normalizedNodeWriter.write(normalizedNode); jsonWriter.flush(); } catch (IOException ioe) { throw new SerializationException(ioe); } return writer; } }
JsonNodeConverter implements NodeConverter { @Override public Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(writer); JSONCodecFactory jsonCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.createLazy(this.schemaContext); URI namespace = schemaNode.getQName().getNamespace(); NormalizedNodeStreamWriter create = JSONNormalizedNodeStreamWriter.createExclusiveWriter(jsonCodecFactory, schemaNode.getPath(), namespace, jsonWriter); try (NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(create)) { normalizedNodeWriter.write(normalizedNode); jsonWriter.flush(); } catch (IOException ioe) { throw new SerializationException(ioe); } return writer; } JsonNodeConverter(final SchemaContext schemaContext); }
JsonNodeConverter implements NodeConverter { @Override public Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(writer); JSONCodecFactory jsonCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.createLazy(this.schemaContext); URI namespace = schemaNode.getQName().getNamespace(); NormalizedNodeStreamWriter create = JSONNormalizedNodeStreamWriter.createExclusiveWriter(jsonCodecFactory, schemaNode.getPath(), namespace, jsonWriter); try (NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(create)) { normalizedNodeWriter.write(normalizedNode); jsonWriter.flush(); } catch (IOException ioe) { throw new SerializationException(ioe); } return writer; } JsonNodeConverter(final SchemaContext schemaContext); @Override Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode); @Override Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode); @Override NormalizedNode<?, ?> deserialize(final SchemaNode schemaNode, final Reader inputData); }
JsonNodeConverter implements NodeConverter { @Override public Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(writer); JSONCodecFactory jsonCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.createLazy(this.schemaContext); URI namespace = schemaNode.getQName().getNamespace(); NormalizedNodeStreamWriter create = JSONNormalizedNodeStreamWriter.createExclusiveWriter(jsonCodecFactory, schemaNode.getPath(), namespace, jsonWriter); try (NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(create)) { normalizedNodeWriter.write(normalizedNode); jsonWriter.flush(); } catch (IOException ioe) { throw new SerializationException(ioe); } return writer; } JsonNodeConverter(final SchemaContext schemaContext); @Override Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode); @Override Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode); @Override NormalizedNode<?, ?> deserialize(final SchemaNode schemaNode, final Reader inputData);  }