Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-226

JSON seems to lose time portion on getObject

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • serialization

    Description

      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

      Attachments

        Activity

          People

            hitesh.khamesra Hitesh Khamesra
            kgignatyev Konstantin Ignatyev
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: