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

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

book

Article ID: 294133

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

Symptoms:

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) 
 :

Environment


Cause

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.

Resolution

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