Lazarus

Free Pascal => General => Topic started by: Frogfather on July 22, 2022, 09:29:26 am

Title: Stringifying a TJSONObject
Post by: Frogfather on July 22, 2022, 09:29:26 am
Hello,

I'm looking for a way to convert a TJSONObject to a string, much the same way as JSON.stringify does it in JS.

I'd thought that TJSONStreamer.ObjectToJSONString() would do the trick, but this returns '{}' despite the fact that the JSON object being passed in definitely has properties.

If the above is the correct approach could someone advise what I'm doing wrong? Otherwise is there a way to do this without rolling my own solution?

Thanks in advance

John C
Title: Re: Stringifying a TJSONObject
Post by: alpine on July 22, 2022, 09:38:51 am
Obj.AsJSON?
Title: Re: Stringifying a TJSONObject
Post by: Frogfather on July 22, 2022, 09:48:08 am
Sometimes the answer is staring you in the face  :-[
Many thanks!
Title: Re: Stringifying a TJSONObject
Post by: alpine on July 22, 2022, 09:51:53 am
You can look at FormatJSON function also, it has some handy format options.
TinyPortal © 2005-2018