spring-geode/src/main/java/org/springframework/geode/data/json/converter/support/JSONFormatterPdxToJsonConverter.java
/**
	 * Decorates the given {@link String JSON} to include the {@literal @type} metadata property in order to
	 * indicate the type of the {@literal JSON} object, which is required for deserialization back to PDX.
	 *
	 * If an {@link JsonProcessingException} is thrown during this operation and if the {@link PdxInstance}
	 * has a {@link #hasValidClassName(PdxInstance) valid class name}, then an attempt is made to serialize
	 * the {@link PdxInstance#getObject() object instance} of the {@link PdxInstance} to {@link String JSON}
	 * using Jackson's {@link ObjectMapper}.
	 *
	 * @param pdxInstance required {@link PdxInstance} from which the {@link String JSON} was serialized;
	 * must not be {@literal null}.
	 * @param json {@link String JSON} generated from the serialization of the {@link PdxInstance};
	 * must not be {@literal null}.
	 * @return the decorated {@link String JSON} including the {@literal @type} metadata property.
	 * @throws DataRetrievalFailureException if {@link String JSON} cannot be decorated with type metadata
	 * and the {@link PdxInstance} is not based on a valid {@link Class} type.
	 * @see JacksonObjectToJsonConverter#convert(Object)
	 * @see org.apache.geode.pdx.PdxInstance
	 * @see #newObjectMapper(Object)
	 */
Decorates the given  String JSON to include the   metadata property in order to
indicate the type of the  JSON object, which is required for deserialization back to PDX.

If an  JsonProcessingException is thrown during this operation and if the  PdxInstance
has a  #hasValidClassName(PdxInstance) valid class name, then an attempt is made to serialize
the  PdxInstance#getObject() object instance of the  PdxInstance to  String JSON
using Jackson's  ObjectMapper.

@param pdxInstance required  PdxInstance from which the  String JSON was serialized;
must not be  null.
@param json  String JSON generated from the serialization of the  PdxInstance;
must not be  null.
@return the decorated  String JSON including the   metadata property.
@throws DataRetrievalFailureException if  String JSON cannot be decorated with type metadata
and the  PdxInstance is not based on a valid  Class type.
Decorates the given String JSON to include the metadata property in order to indicate the type of the JSON object which is required for deserialization back to PDX . If an JsonProcessingException is thrown during this operation and if the PdxInstance has a #hasValidClassName ( PdxInstance ) valid class name then an attempt is made to serialize the PdxInstance#getObject () object instance of the PdxInstance to String JSON using Jackson ' s ObjectMapper . @param pdxInstance required PdxInstance from which the String JSON was serialized ; must not be null . @param json String JSON generated from the serialization of the PdxInstance ; must not be null . @return the decorated String JSON including the metadata property . @throws DataRetrievalFailureException if String JSON cannot be decorated with type metadata and the PdxInstance is not based on a valid Class type .
@SuppressWarnings("unused")
	protected @NonNull String decorate(@NonNull PdxInstance pdxInstance, @NonNull String json) {
		if (isDecorationRequired(pdxInstance, json)) {
			try {
				ObjectMapper objectMapper = newObjectMapper(json);
				JsonNode jsonNode = objectMapper.readTree(json);
				if (isMissingObjectTypeMetadata(jsonNode)) {
					((ObjectNode) jsonNode).put(AT_TYPE_METADATA_PROPERTY_NAME, pdxInstance.getClassName());
					json = objectMapper.writeValueAsString(jsonNode);
				}
				return json;
			}
			catch (JsonProcessingException cause) {
				if (hasValidClassName(pdxInstance)) {
					return convertPojoToJson(pdxInstance.getObject());
				}
				String message = String.format("Failed to parse JSON [%s]", json);
				throw new DataRetrievalFailureException(message, cause);
			}
		}
		return json;
	}
@ SuppressWarnings ( "unused" ) protected @ NonNull String decorate ( @ NonNull PdxInstance pdxInstance , @ NonNull String json ) { if ( isDecorationRequired ( pdxInstance , json ) ) { try { ObjectMapper objectMapper = newObjectMapper ( json ) ; JsonNode jsonNode = objectMapper . readTree ( json ) ; if ( isMissingObjectTypeMetadata ( jsonNode ) ) { ( ( ObjectNode ) jsonNode ) . put ( AT_TYPE_METADATA_PROPERTY_NAME , pdxInstance . getClassName ( ) ) ; json = objectMapper . writeValueAsString ( jsonNode ) ; } return json ; } catch ( JsonProcessingException cause ) { if ( hasValidClassName ( pdxInstance ) ) { return convertPojoToJson ( pdxInstance . getObject ( ) ) ; } String message = String . format ( "Failed to parse JSON [%s]" , json ) ; throw new DataRetrievalFailureException ( message , cause ) ; } } return json ; }
Decorates the given {@link String JSON} to include the {@literal @type} metadata property in order to
 indicate the type of the {@literal JSON} object, which is required for deserialization back to PDX.
Decorates the given { @link String JSON } to include the { @literal @type } metadata property in order to indicate the type of the { @literal JSON } object which is required for deserialization back to PDX .