agave-metadata/metadata-core/src/main/java/org/iplantc/service/metadata/model/MetadataItemCodec.java
/**
     * Writes the given jsonNode to the BsonWriter. This method allows for recursion to
     * support both primary types, ObjectNodes, and ArrayNodes.
     *
     * @param writer the active writer for the metadata item codec encoding.
     * @param jsonNode the jsonNode to process
     */
Writes the given jsonNode to the BsonWriter. This method allows for recursion to
support both primary types, ObjectNodes, and ArrayNodes.

@param writer the active writer for the metadata item codec encoding.
@param jsonNode the jsonNode to process
Writes the given jsonNode to the BsonWriter . This method allows for recursion to support both primary types ObjectNodes and ArrayNodes . @param writer the active writer for the metadata item codec encoding . @param jsonNode the jsonNode to process
public void encodeJsonNode(BsonWriter writer, JsonNode jsonNode) {
        if (jsonNode == null) {
            writer.writeNull();
        } else if (jsonNode.isValueNode()) {
            if (jsonNode.isIntegralNumber()) {
                writer.writeInt32(jsonNode.intValue());
            } else if (jsonNode.isFloatingPointNumber()) {
                writer.writeDouble(jsonNode.asDouble());
            } else if (jsonNode.isBoolean()) {
                writer.writeBoolean(jsonNode.asBoolean());
            } else {
                writer.writeString(jsonNode.textValue());
            }
        } else if (jsonNode.isArray()) {
            writer.writeStartArray();
            jsonNode.forEach(item -> encodeJsonNode(writer, item));
            writer.writeEndArray();
        } else {
            try {
                String jsonValueString = objectMapper.writeValueAsString(jsonNode);
                BsonDocument bsonDocument = BsonDocument.parse(jsonValueString);
                BsonReader bsonReader = new BsonDocumentReader(bsonDocument);
                writer.pipe(bsonReader);
            }
            catch (JsonProcessingException e) {
                log.error("Failed to serialize value for metadata value " + jsonNode.asText(), e);
                writer.writeString(jsonNode.asText());
            }
        }
    }
public void encodeJsonNode ( BsonWriter writer , JsonNode jsonNode ) { if ( jsonNode == null ) { writer . writeNull ( ) ; } else if ( jsonNode . isValueNode ( ) ) { if ( jsonNode . isIntegralNumber ( ) ) { writer . writeInt32 ( jsonNode . intValue ( ) ) ; } else if ( jsonNode . isFloatingPointNumber ( ) ) { writer . writeDouble ( jsonNode . asDouble ( ) ) ; } else if ( jsonNode . isBoolean ( ) ) { writer . writeBoolean ( jsonNode . asBoolean ( ) ) ; } else { writer . writeString ( jsonNode . textValue ( ) ) ; } } else if ( jsonNode . isArray ( ) ) { writer . writeStartArray ( ) ; jsonNode . forEach ( item -> encodeJsonNode ( writer , item ) ) ; writer . writeEndArray ( ) ; } else { try { String jsonValueString = objectMapper . writeValueAsString ( jsonNode ) ; BsonDocument bsonDocument = BsonDocument . parse ( jsonValueString ) ; BsonReader bsonReader = new BsonDocumentReader ( bsonDocument ) ; writer . pipe ( bsonReader ) ; } catch ( JsonProcessingException e ) { log . error ( "Failed to serialize value for metadata value " + jsonNode . asText ( ) , e ) ; writer . writeString ( jsonNode . asText ( ) ) ; } } }
Writes the given jsonNode to the BsonWriter.
Writes the given jsonNode to the BsonWriter .