Pivotal Knowledge Base


Cannot convert PdxInstance with a field of type "Date" into JSON document


Pivotal GemFire 7.0.2.x or later (observed with GemFire 8.2.x)


This article provides a resolution for the issue when you try to convert a PdxInstance into a JSON document, when one of the field's type is "Date", using a JSONFormatter.


When attempting this conversion, you may see the following exception and fail to get a JSON document:

Log Message:

Could not create JSON document from PdxInstance 
com.gemstone.gemfire.pdx.JSONFormatterException: Could not create JSON document from PdxInstance
at com.gemstone.gemfire.pdx.JSONFormatter.toJSON(JSONFormatter.java:103)
Caused by: java.lang.IllegalStateException: PdxInstance returns unknwon pdxfield approvedOn for type Tue May 23 10:20:55 JST 2017
at com.gemstone.gemfire.pdx.internal.json.PdxToJSON.writeValue(PdxToJSON.java:173)


GemFire's JSONFormatter uses the jackson-core library internally to convert data between JSON documents and actual PdxInstances.  However, the jackson-core library does not support the "Date" type.


You should change the "Date" type field of the PdxInstance into another type supported by jackson-core, such as a "Long" with timestamp expression.


Powered by Zendesk