Published on InterSystems Developer Community (https://community.intersystems.com)

Home > JSON, Cache and Date/Time

Question
Eduard Lebedyuk · Apr 19, 2016

JSON, Cache and Date/Time

I have a Cache classes with %TimeStamp (e.g. 2016-04-18 12:29:11) and %Date (eg. 64027) properties. And I have a javascript client app, which needs full CRUD over this properties.

But in javascript date/time are defined by ISO8601 (e.g. timestamp 2016-04-18T12:29:11Z, date 2016-04-18).

Communication between a server and a client on a server side are done via following classes/methods:

  • SQL → JSON via %ZEN.Auxiliary.jsonSQLProvider:%WriteJSONFromSQL
  • Object → JSON via  %ZEN.Auxiliary.jsonProvider:%WriteJSONFromObject
  • JSON → Object via  %ZEN.Auxiliary.jsonProvider:%ConvertJSONToObject
  • Dynamic Object → JSON via %Library.AbstractObject:$toJSON
  • JSON → Dynamic Object  via %Library.AbstractObject:$fromJSON

The question is, how can I  enable all this types of communication with:

  • no work on a client side (client always receives/sends ISO8601 timestamp/date)
  • minimum amount of work on a server side for each new property

Restrictions: I can't just use %String because Cache classes are also used by other Cache applications with SQL and object access and they may require ORDER BY date/time values, etc.

#JavaScript #JSON #Object Data Model #REST API #Frontend #Caché

Source URL:https://community.intersystems.com/post/json-cache-and-datetime