we are dealing with a serious problem with the jsonEncode(...) and jsonDecode(...) function. I have prepared a small example:
Code: Select all
public void testTimeJson() {
time t;
t = makeTime(2020,01,10,15,38,12);
DebugTN("saved Time:", t);
string tJson = jsonEncode(t);
DebugTN("json String:" ,tJson);
//First test using dyn_anytype first and then cast to time
dyn_anytype decoded1 = jsonDecode(tJson);
DebugTN("decoded1:",decoded1);
time decodedTime1 = (time)decoded1[1];
DebugTN("decodedTime1:",decodedTime1);
//Second test, direct cast to time
time decodedTime2 = jsonDecode(tJson);
DebugTN("decodedTime2:",decodedTime2);
}
Code: Select all
WCCOAui (2), 2020.01.10 14:55:03.882, CTRL, WARNING, 5/ctrl, Ort der folgenden Meldung:
Module: _QuickTest_
Panel: ..testJson.xml []
Script: Initialize
In panel scope library: testJson.xml []
Line: 19
WCCOAui (2), 2020.01.10 14:55:03.882, IMPL, WARNING, 50, Default branch called, TimeVar, operator=, cannot assign variable of type DYNANYTYPE_VAR
WCCOAui2:2020.01.10 14:55:03.882["saved Time:"][2020.01.10 15:38:12.000000000]
WCCOAui2:2020.01.10 14:55:03.882["json String:"]["[\"2020-01-10T14:38:12.000Z\"]"]
WCCOAui2:2020.01.10 14:55:03.882["decoded1:"][dyn_anytype 1 items
WCCOAui2: 1: "2020-01-10T14:38:12.000Z"
WCCOAui2:]
WCCOAui2:2020.01.10 14:55:03.882["decodedTime1:"][2020.01.10 23:38:12.000000000]
WCCOAui2:2020.01.10 14:55:03.902["decodedTime2:"][1970.01.01 01:00:00.000000000]Is this an error or are we using the wrong way to decode the time?
Thanks and with best regards,
moTo