class JsonNodeConverter implements NodeConverter {

    @Override
    public Writer serializeRpc(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);
        String localName = schemaNode.getQName().getLocalName();
        URI namespace = schemaNode.getQName().getNamespace();
        NormalizedNodeStreamWriter create = JSONNormalizedNodeStreamWriter.createExclusiveWriter(jsonCodecFactory,
                schemaNode.getPath(), namespace, jsonWriter);
        try (NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(create)) {
            jsonWriter.beginObject().name(localName);
            for (NormalizedNode<?, ?> child : ((ContainerNode) normalizedNode).getValue()) {
                normalizedNodeWriter.write(child);
            }
            // XXX dirty check for end of object. When serializing RPCs with input/output which is not a
            // container
            // the object is not closed.
            if (!writer.toString().endsWith("}")) {
                jsonWriter.endObject();
            }
        } catch (IOException ioe) {
            throw new SerializationException(ioe);
        }
        return writer;
    }

    public  JsonNodeConverter(final SchemaContext schemaContext);

}