You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Darrel Schneider (JIRA)" <ji...@apache.org> on 2016/02/06 00:31:40 UTC

[jira] [Updated] (GEODE-226) JSON seems to lose time portion on getObject

     [ https://issues.apache.org/jira/browse/GEODE-226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Darrel Schneider updated GEODE-226:
-----------------------------------
    Component/s:     (was: core)
                 serialization

> JSON seems to lose time portion on getObject
> --------------------------------------------
>
>                 Key: GEODE-226
>                 URL: https://issues.apache.org/jira/browse/GEODE-226
>             Project: Geode
>          Issue Type: Bug
>          Components: serialization
>            Reporter: Konstantin Ignatyev
>            Assignee: Hitesh Khamesra
>
> com.gemstone.gemfire.pdx.internal.PdxInstanceImpl#getObject
> Date format, in the JSON land it is pretty much settled to be ISO 8661
> https://weblog.west-wind.com/posts/2014/Jan/06/JavaScript-JSON-Date-Parsing-and-real-Dates 
> It would  be nice to be able to have Geode’s JSON standard compliant, or have this configurable. Otherwise the we will be loosing time portion of date-s
> public Object getObject() {
>   if (getPdxType().getNoDomainClass()) { 
>     //In case of Developer Rest APIs, All PdxInstances converted from Json will have a className =__GEMFIRE_JSON.
>     //Following code added to convert Json/PdxInstance into the Java object.
>     if(this.getClassName().equals("__GEMFIRE_JSON")){
>       
>       //introspect the JSON, does the @type meta-data exist.
>       String className = extractTypeMetaData();
>       
>       if(StringUtils.hasText(className)) {
>         try {
>           ObjectMapper mapper = new ObjectMapper();
>           mapper.setDateFormat(new SimpleDateFormat("MM/dd/yyyy"));
>           mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
>           mapper.configure(com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
>           String JSON = JSONFormatter.toJSON(this);
>           Object classInstance = mapper.readValue(JSON, ClassPathLoader.getLatest().forName(className));
>           return classInstance;
>         }catch(Exception e){
>           throw new PdxSerializationException("Could not deserialize as java class type could not resolved", e);
>         }
>       }
>     }
>     return this;
>   }
> Also this method is not that performant, please see #225 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)