/** * Method that can be called to serialize this node and * all of its descendants using specified JSON generator. */ @Override public void serialize(JsonGenerator g, SerializerProvider provider) throws IOException { @SuppressWarnings("deprecation") boolean trimEmptyArray = (provider != null) && !provider.isEnabled(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS); g.writeStartObject(this); for (Map.Entry<String, JsonNode> en : _children.entrySet()) { /* 17-Feb-2009, tatu: Can we trust that all nodes will always * extend BaseJsonNode? Or if not, at least implement * JsonSerializable? Let's start with former, change if * we must. */ BaseJsonNode value = (BaseJsonNode) en.getValue(); // as per [databind#867], see if WRITE_EMPTY_JSON_ARRAYS feature is disabled, // if the feature is disabled, then should not write an empty array // to the output, so continue to the next element in the iteration if (trimEmptyArray && value.isArray() && value.isEmpty(provider)) { continue; } g.writeFieldName(en.getKey()); value.serialize(g, provider); } g.writeEndObject(); }
@Override public void serializeWithType(JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { @SuppressWarnings("deprecation") boolean trimEmptyArray = (provider != null) && !provider.isEnabled(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS); WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, typeSer.typeId(this, JsonToken.START_OBJECT)); for (Map.Entry<String, JsonNode> en : _children.entrySet()) { BaseJsonNode value = (BaseJsonNode) en.getValue(); // check if WRITE_EMPTY_JSON_ARRAYS feature is disabled, // if the feature is disabled, then should not write an empty array // to the output, so continue to the next element in the iteration if (trimEmptyArray && value.isArray() && value.isEmpty(provider)) { continue; } g.writeFieldName(en.getKey()); value.serialize(g, provider); } typeSer.writeTypeSuffix(g, typeIdDef); }
/** * Method that can be called to serialize this node and * all of its descendants using specified JSON generator. */ @Override public void serialize(JsonGenerator g, SerializerProvider provider) throws IOException { @SuppressWarnings("deprecation") boolean trimEmptyArray = (provider != null) && !provider.isEnabled(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS); g.writeStartObject(this); for (Map.Entry<String, JsonNode> en : _children.entrySet()) { /* 17-Feb-2009, tatu: Can we trust that all nodes will always * extend BaseJsonNode? Or if not, at least implement * JsonSerializable? Let's start with former, change if * we must. */ BaseJsonNode value = (BaseJsonNode) en.getValue(); // as per [databind#867], see if WRITE_EMPTY_JSON_ARRAYS feature is disabled, // if the feature is disabled, then should not write an empty array // to the output, so continue to the next element in the iteration if (trimEmptyArray && value.isArray() && value.isEmpty(provider)) { continue; } g.writeFieldName(en.getKey()); value.serialize(g, provider); } g.writeEndObject(); }
/** * Method that can be called to serialize this node and * all of its descendants using specified JSON generator. */ @Override public void serialize(JsonGenerator g, SerializerProvider provider) throws IOException { @SuppressWarnings("deprecation") boolean trimEmptyArray = (provider != null) && !provider.isEnabled(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS); g.writeStartObject(this); for (Map.Entry<String, JsonNode> en : _children.entrySet()) { /* 17-Feb-2009, tatu: Can we trust that all nodes will always * extend BaseJsonNode? Or if not, at least implement * JsonSerializable? Let's start with former, change if * we must. */ BaseJsonNode value = (BaseJsonNode) en.getValue(); // as per [databind#867], see if WRITE_EMPTY_JSON_ARRAYS feature is disabled, // if the feature is disabled, then should not write an empty array // to the output, so continue to the next element in the iteration if (trimEmptyArray && value.isArray() && value.isEmpty(provider)) { continue; } g.writeFieldName(en.getKey()); value.serialize(g, provider); } g.writeEndObject(); }
@Override public void serializeWithType(JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { @SuppressWarnings("deprecation") boolean trimEmptyArray = (provider != null) && !provider.isEnabled(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS); typeSer.writeTypePrefixForObject(this, g); for (Map.Entry<String, JsonNode> en : _children.entrySet()) { BaseJsonNode value = (BaseJsonNode) en.getValue(); // check if WRITE_EMPTY_JSON_ARRAYS feature is disabled, // if the feature is disabled, then should not write an empty array // to the output, so continue to the next element in the iteration if (trimEmptyArray && value.isArray() && value.isEmpty(provider)) { continue; } g.writeFieldName(en.getKey()); value.serialize(g, provider); } typeSer.writeTypeSuffixForObject(this, g); }
@Override public void serializeWithType(JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { @SuppressWarnings("deprecation") boolean trimEmptyArray = (provider != null) && !provider.isEnabled(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS); WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, typeSer.typeId(this, JsonToken.START_OBJECT)); for (Map.Entry<String, JsonNode> en : _children.entrySet()) { BaseJsonNode value = (BaseJsonNode) en.getValue(); // check if WRITE_EMPTY_JSON_ARRAYS feature is disabled, // if the feature is disabled, then should not write an empty array // to the output, so continue to the next element in the iteration if (trimEmptyArray && value.isArray() && value.isEmpty(provider)) { continue; } g.writeFieldName(en.getKey()); value.serialize(g, provider); } typeSer.writeTypeSuffix(g, typeIdDef); }