Hi
Are there any examples of building JSON objects in TMS WebCore ?
I have successfully used TJSON, TJSONObject + TJSON Array to parse responses from REST services but when building request with more complicated structure than just single name value structure I get empty arrays.
Target to create is something like this :
{"Array1" : [{"key1" : "Value1"}, {"key2": "value2"}]}
Regards
Eirik
Just after I reqgistered this I found Bruno's response on this :
Hi, What is the best reference for json handling with TMS webcore. I'd also would like to produce efficient code. I'm little bit confused with TJsonObject, TJsObject etc.Especially this is hard because my code completion isn't working.
Solved it for me
procedure TForm1.WebButtonParseClick(Sender: TObject);
var
lJSONObject : TJSONObject;
lArrayObject : TJSONObject;
lJSONArray : TJSONArray;
begin
lJSONObject := TJSONObject.Create;
lJSONObject.AddPair('key1', 'value1');
lJSONObject.AddPair('key2', 'value2');
lJSONArray := TJSONArray.Create;
lJSONArray.Add(lJSONObject);
lArrayObject := TJSONObject.Create;
lArrayObject.AddPair('Array1', lJSONArray);
WebMemoLog.Lines.Add(LArrayObject.ToString);
lArrayObject.Free;
lJSONArray.Free;
lJSONObject.Free;
end;
Regards
Eirik
system
(system)
Closed
October 26, 2020, 2:46pm
3
This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.