You are not logged in.
I have server based on interfaced services.
In service I have method:
function GetAnnouncementList(out aAnnouncementList: TAnnouncementDataList): Integer;
where:
TAnnouncementDataList = TArray<RAnnouncementData>;
RAnnouncementData = record
UUID : TAnnouncementUUID;
ReleaseTimestamp: TUnixTimestampUTC;
DeadTimestamp : TUnixTimestampUTC;
Topic: RawUTF8;
ContentsType: SmallInt;
TagList : RawJSON; <------------------------------------------ this is problematic
DemoVersionMode : AnsiChar;
PersonKind : AnsiChar;
end;
On client side I get this array like:
{"result":[[{"UUID":"16551D01-CA15-4B32-BDFB-F5D0BDDA42E7","ReleaseTimestamp":1484210095,"DeadTimestamp":1486767600,"Topic":"Msg from: 2017-01-12 09:34:54","ContentsType":66,
"TagList":"{"Tag":["11","22","33","44"]}","DemoVersionMode":76,"PersonKind":78},{"UUID":"FB5A930F-3D3C-4395-B4AC-81CA639E490C","ReleaseTimestamp":1484210097,"DeadTimestamp":1486767600,"Topic":"Msg from: 2017-01-12 09:34:57","ContentsType":66,
"TagList":"{"Tag":["11","22","33","44"]}","DemoVersionMode":76,"PersonKind":78}],2]}
Pay attention that TagList has quotes around:
--->"{"Tag":["11","22","33","44"]}"<---
and client raise exception EInterfaceFactoryException on decoding this:
''Invalid returned JSON content: expects {result:...}, got {"result~~[[{"UUID":"16551D01-CA15-4B32-BDFB-F5D0BDDA42E7","ReleaseTimestamp":1484210095,"DeadTimestamp":1486767600,"Topic":"Wiadomość z chwili: 2017-01-12 09:34:54","ContentsType":66,"TagList":"{"Tag":["11","22","33","44"]}","DemoVersionMode":76,"PersonKind":78},{"UUID":"FB5A930F-3D3C-4395-B4AC-81CA639E490C","ReleaseTimestamp":1484210097,"DeadTimestamp":1486767600,"Topic":"Wiadomość z chwili: 2017-01-12 09:34:57","ContentsType":66,"TagList":"{"Tag":["11","22","33","44"]}","DemoVersionMode":76,"PersonKind":78}],2]}''
I generate the JSON in business code on the server side and I want to send it to the client.
What am I doing wrong? How can I do this right?
Last edited by jaclas (2017-01-18 08:53:40)
Offline
Hi, experiment to return the method as boolean.
Offline
Offline
Problem is no with record, but with field of type RawJSON that is coded with additional quotes and on client side decoding of server response raise error. Without this field call is sucessful.
{"UUID":"16551D01-CA15-4B32-BDFB-F5D0BDDA42E7",
"ReleaseTimestamp":1484210095,
"DeadTimestamp":1486767600,
"Topic":"Msg from: 2017-01-12 09:34:54",
"ContentsType":66,
"TagList":"{"Tag":["11","22","33","44"]}", <---- see this, JSON parser not decoding this strange item
"DemoVersionMode":76,
"PersonKind":78}}
It seems to me that the type of RawJSON should be wrapped (be escaped).
Last edited by jaclas (2017-01-18 13:14:10)
Offline
If you change the type RawJSON to RawUTF8?
Offline
Offline
If you change the type RawJSON to RawUTF8?
It helped (escaping string in response), thx.
But I don't understand what is the type of RawJSON?
Offline
There was a bug in TJSONCustomParserRTTI.WriteOneLevel.
Please check http://synopse.info/fossil/info/a43c1620e1
Offline
Thanks! But why do you paste three point list for me? ;-)
Offline
I knew that these points was blind ;-P
Offline