Snorri,
In researching I came across this thread
https://stackoverflow.com/questions/10286204/the-right-json-date-format which includes the answer because XKCD says so
https://xkcd.com/1179/ :-)
By using ISO-8601 we should be good with using JSON to pass arguments to WebComponents
As "DATE" is not a known JSON datatype, I have no way of knowing if the STRING I get using the .get() method is a DATE or not.
therein lies the problem, we don't know either
This works fine with all numeric and string datatypes but I guess I will need to apply some conversions to boolean and datetime as well :(
Boolean is a JSON data-type so shouldn't be a problem. Datetime I'd expect us to use ISO-8601 as well but a quick check I don't see any T or Z in our output. I am not 100% sure on the standard if Z,T mandatory or optional but I can imagine if we output "2019-12-04T09:00:00Z" instead of "2019-12-04 09:00:00" then that would cause a similar issue to what you are encountering with DATE, but for now (fortunately as it maybe we don't put T or Z into the datetime string) seems to be ok. Also interestingly with numbers being a JSON data-type, I experimented with DBFORMAT and that does handle case of being able to assign appropriately (I tried with DBFORMAT using , as decimal point)
That point with datetime reminded me of the options we have with XML Serializer
http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/r_gws_XmlSerializer_option_flags.html. It maybe that what you want is a similar option with JSON serialization ie use DBDATE or ISO-8601 with JSON serialization
Finally I also want to make sure that it is understood that with
LET date_variable = js.get("date_element")
js.get is returning a string in that instance. So you have
LET date_variable = string
and the normal string to date conversion is taking place. And as you discover the date in ISO-8601 format is not converted.
With util.JSONObject.toFGL as in
CALL js.toFGL(r)
http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ext_util_JSONObject_toFGL.htmlthat is effectively passing the data-type across and so has that information so as to parse the information.
Reuben