Hi DFCoders
I've to build a RESTful Web Server, returning JSON.
At this stage it is only a GET, so not issues with additional VERBS yet.
I know of the IIS rewrite to make it 'prettier' but for now happy with the long way of the generated pages.
So in 19.0 I created the following code:
Code:
Struct Struct1a
String StringA
String StringB
String StringC
End_Struct
Struct Struct1b
String StringA
String StringB
String StringC
End_Struct
Struct Struct1
String StringA
String StringB
String StringC
Struct1a Str1a
Struct1b[] Str1b
End_Struct
{ Published=True }
{ Description="" }
Function SimpleRequest String sRequest Returns String
String sResponse
Struct1 myData
Handle hJson
Get Create (RefClass(cJsonObject)) to hJson
Send DataTypeToJson to hJson myData
Get Stringify of hJson to sResponse
Send Destroy of hJson
Function_Return sResponse
End_Function
And tested the result with the url.
http://localhost/RF01/tempService.ws...g?sRequest=123
To my surprise I get returned:
"{\"StringA\":\"\",\"StringB\":\"\",\"StringC\":\" \",\"Str1a\":{\"StringA\":\"\",\"StringB\":\"\",\" StringC\":\"\"},\"Str1b\":[]}"
Now, I understand that any values should be escaped, but I did not expect the structure itself to be escaped.
Any client, even JavaScript cannot eval this and work with it.
Now it is late and I had a long day, but what am I missing?
Returning UChar[] in UTF8 is even more confusing again.
Any help much appreciated!
Kind regards
Marco