You are not logged in.
procedure TfmlJson.btnO2JClick(Sender: TObject);
var
TestObj:TMyTest;
s:RawUTF8;
begin
TestObj:=TMyTest.Create;
TestObj.ITEM_ID:=1;
TestObj.ITEM_NAME:='mainItem';
TestObj.MyDate:=Now;
TestObj.AddChild(11,'subItem11');
TestObj.AddChild(12,'subItem12');
Memo1.Lines.Add( ObjectToJSON(TestObj,[woHumanReadable,woDontStoreDefault,woObjectListWontStoreClassName]));
TestObj.Free;
end;
==================
{
"ChildList":
[{
"CHILD_ID": 11,
"CHILD_NAME": "subItem11"
},{
"CHILD_ID": 12,
"CHILD_NAME": "subItem12"
}
],
"ITEM_ID": 1,
"ITEM_NAME": "mainItem",
"MyDate": "2017-09-05T10:03:14"
}
{
"ChildList":
[{
"CHILD_ID": 11,
"CHILD_NAME": "subItem11"
},{
"CHILD_ID": 12,
"CHILD_NAME": "subItem12"
}
],
"ITEM_ID": 1,
"ITEM_NAME": "mainItem",
"MyDate": "2017-09-05T10:03:34"
}
{
"ChildList":
[{
"CHILD_ID": 11,
"CHILD_NAME": "subItem11"
},{
"CHILD_ID": 12,
"CHILD_NAME": "subItem12"
}
],
"ITEM_ID": 1,
"ITEM_NAME": "mainItem",
"MyDate": "2017-09-05T10:03:35"
}
{
"ChildList":
[{
"CHILD_ID": 11,
"CHILD_NAME": "subItem11"
},{
"CHILD_ID": 12,
"CHILD_NAME": "subItem12"
}
],
"ITEM_ID": 1,
"ITEM_NAME": "mainItem",
"MyDate": "2017-09-05T10:03:35"
}
===="MyDate": "2017-09-05T10:03:35"
here 'T' in the middle. what happen ?
Last edited by linbren (2017-09-07 08:37:21)
Windows 7 64bit. Delphi XE10.2 Professional.
Offline
Please follow the forum rules.
https://synopse.info/forum/misc.php?action=rules
Don't post such extensive source code in the forum.
About your question, the framework generates valid ISO-8601 timestamp text.
It includes a 'T' by standard.
Offline
sorry for break the rule .
while i don't need the 'T' here, how to avoid it ?
Windows 7 64bit. Delphi XE10.2 Professional.
Offline
I'd like to have one more option such like [woDateTimeSimple] .
they are many conveniences while there are fields defined as TDATETIME in database .
Windows 7 64bit. Delphi XE10.2 Professional.
Offline
Adding an option to generate non standard date time does not make sense at all.
What is your problem with the "T" character?
The JSON should use standard encoding, i.e. proper ISO-8601. JSON is used to transmit values per representation - not for presentation.
It is up to the client application to convert it back to TDateTime value, then display it as expected, with the display format as expected by the end user locale.
Offline