Gemfire JavaDocs
Class JSONFormatter
- java.lang.Object
-
- org.apache.geode.pdx.JSONFormatter
-
@Deprecated public class JSONFormatter extends java.lang.Object
Deprecated.since GemFire 10.0, please use theRegionService.getJsonDocumentFactory(StorageFormat)
instead.JSONFormatter has a static method
fromJSON(String, String...)
to convert a JSON document into aPdxInstance
and a static methodtoJSON(PdxInstance)
to convert aPdxInstance
into a JSON Document.Using these methods an applications may convert a JSON document into a PdxInstance for storing in the cache. Indexes can then be defined on the PdxInstances so that queries can be performed using OQL. Queries will return PdxInstances and these can be turned back back into JSON documents using JSONFormatter.
JSONFormatter treats values in a json document as number(byte, short, int, long..), string, array, object, 'true', 'false' or 'null'. These correspond to the following java types:
Notifications JSON Java object PdxInstance
arrays LinkedList
BigDecimal BigDecimal
BigInterger BigInteger
Double double float float boolean boolean Integer byte, short or int null null
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
JSON_CLASSNAME
Deprecated.static java.lang.String
SORT_JSON_FIELD_NAMES_PROPERTY
Deprecated.By setting "gemfire.sort-json-field-names" to true, enables serialization of JSON field in JSON document to be sorted.
-
Constructor Summary
Constructors Constructor Description JSONFormatter()
Deprecated.JSONFormatter(RegionService regionService)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static PdxInstance
fromJSON(byte[] jsonByteArray)
Deprecated.Converts a Byte Array JSON document into a PdxInstancestatic PdxInstance
fromJSON(byte[] jsonByteArray, java.lang.String... identityFields)
Deprecated.Converts a Byte Array JSON document into a PdxInstancestatic PdxInstance
fromJSON(java.lang.String jsonString)
Deprecated.Converts a String JSON document into a PdxInstancestatic PdxInstance
fromJSON(java.lang.String jsonString, java.lang.String... identityFields)
Deprecated.Converts a String JSON document into a PdxInstancejava.lang.String
fromPdxInstance(PdxInstance pdxInstance)
Deprecated.Converts a PdxInstance into a JSON documentRegionService
getRegionService()
Deprecated.static java.lang.String
toJSON(PdxInstance pdxInstance)
Deprecated.Converts a PdxInstance into a JSON document in String formstatic byte[]
toJSONByteArray(PdxInstance pdxInstance)
Deprecated.Converts a PdxInstance into a JSON document in byte-array formbyte[]
toJsonByteArrayFromPdxInstance(PdxInstance pdxInstance)
Deprecated.Converts a PdxInstance into a JSON document in byte-array formPdxInstance
toPdxInstance(java.lang.Object json, java.lang.String... identityFields)
Deprecated.Converts a JSON document (String or Byte Array) into a PdxInstance
-
-
-
Field Detail
-
JSON_CLASSNAME
public static final java.lang.String JSON_CLASSNAME
Deprecated.- See Also:
- Constant Field Values
-
SORT_JSON_FIELD_NAMES_PROPERTY
public static final java.lang.String SORT_JSON_FIELD_NAMES_PROPERTY
Deprecated.By setting "gemfire.sort-json-field-names" to true, enables serialization of JSON field in JSON document to be sorted. That can help to reduce the number of pdx typeId generation if different JSON documents have same fields in the different order.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JSONFormatter
public JSONFormatter()
Deprecated.
-
JSONFormatter
public JSONFormatter(RegionService regionService)
Deprecated.
-
-
Method Detail
-
getRegionService
public RegionService getRegionService()
Deprecated.
-
fromJSON
public static PdxInstance fromJSON(java.lang.String jsonString)
Deprecated.Converts a String JSON document into a PdxInstance- Parameters:
jsonString
- The JSON String to convert to PDX- Returns:
- The PdxInstance
- Throws:
JSONFormatterException
- if unable to create the PdxInstance
-
fromJSON
public static PdxInstance fromJSON(java.lang.String jsonString, java.lang.String... identityFields)
Deprecated.Converts a String JSON document into a PdxInstance- Parameters:
jsonString
- The JSON String to convert to PDXidentityFields
- Any desired identity fields on the JSON object to be used for equals and hashCode computations- Returns:
- The PdxInstance
- Throws:
JSONFormatterException
- if unable to create the PdxInstance
-
fromJSON
public static PdxInstance fromJSON(byte[] jsonByteArray)
Deprecated.Converts a Byte Array JSON document into a PdxInstance- Parameters:
jsonByteArray
- The JSON Object as a byte array to convert to PDX- Returns:
- The PdxInstance
- Throws:
JSONFormatterException
- if unable to create the PdxInstance
-
fromJSON
public static PdxInstance fromJSON(byte[] jsonByteArray, java.lang.String... identityFields)
Deprecated.Converts a Byte Array JSON document into a PdxInstance- Parameters:
jsonByteArray
- The JSON Object as a byte array to convert to PDXidentityFields
- Any desired identity fields on the JSON object to be used for equals and hashCode computations- Returns:
- The PdxInstance
- Throws:
JSONFormatterException
- if unable to create the PdxInstance
-
toPdxInstance
public PdxInstance toPdxInstance(java.lang.Object json, java.lang.String... identityFields)
Deprecated.Converts a JSON document (String or Byte Array) into a PdxInstance- Parameters:
json
- The JSON document (String or Byte Array) to convert to PDXidentityFields
- Any desired identity fields on the JSON object to be used for equals and hashCode computations- Returns:
- The PdxInstance
- Throws:
JSONFormatterException
- if unable to create the PdxInstance
-
toJSON
public static java.lang.String toJSON(PdxInstance pdxInstance)
Deprecated.Converts a PdxInstance into a JSON document in String form- Parameters:
pdxInstance
- the JSON string.- Returns:
- the JSON string JSONFormatterException if unable to create the JSON document
-
fromPdxInstance
public java.lang.String fromPdxInstance(PdxInstance pdxInstance)
Deprecated.Converts a PdxInstance into a JSON document- Parameters:
pdxInstance
- The PdxInstance to convert- Returns:
- the JSON string
- Throws:
JSONFormatterException
- if unable to create the JSON document
-
toJSONByteArray
public static byte[] toJSONByteArray(PdxInstance pdxInstance)
Deprecated.Converts a PdxInstance into a JSON document in byte-array form- Parameters:
pdxInstance
- The PdxInstance to convert- Returns:
- the JSON byte array
- Throws:
JSONFormatterException
- if unable to create the JSON document
-
toJsonByteArrayFromPdxInstance
public byte[] toJsonByteArrayFromPdxInstance(PdxInstance pdxInstance)
Deprecated.Converts a PdxInstance into a JSON document in byte-array form- Parameters:
pdxInstance
- The PdxInstance to convert- Returns:
- the JSON byte array
- Throws:
JSONFormatterException
- if unable to create the JSON document
-
-