You are not logged in.
Pages: 1
Hi all!
When make json string using IDocList, the escape char is added to the result.
var
LDocList: IDocList;
begin
LDocList := DocList('[]');
LDocList.Append('{"text": "test"}');
ShowMessage(LDocList.Json); //shows '["{\"text\": \"test\"}"]'
How to get unescaped json string with IDocList?
Offline
Hi, because it's a string, it's appending a string item to a json array.
Use IDocDict to add an object:
LDocList.AppendDoc(DocDict(['text', 'test']));
or you can serialize directly:
LDocList.Json := '[{"text": "test"},{"text": "test2"}]'; // don't make sense: `DocList('[{"text": "test"}]');`
when the array (Len) is not empty, you can assign an object directly to it using:
LDocList.O[1] := DocDict(['text', 'test2 is now test3']);
Last edited by flydev (2025-07-17 14:45:43)
Offline
Pages: 1