Recent

Author Topic: Stringifying a TJSONObject  (Read 249 times)

Frogfather

  • New Member
  • *
  • Posts: 45
Stringifying a TJSONObject
« 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

y.ivanov

  • Sr. Member
  • ****
  • Posts: 499
Re: Stringifying a TJSONObject
« Reply #1 on: July 22, 2022, 09:38:51 am »
Obj.AsJSON?
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Frogfather

  • New Member
  • *
  • Posts: 45
Re: Stringifying a TJSONObject
« Reply #2 on: July 22, 2022, 09:48:08 am »
Sometimes the answer is staring you in the face  :-[
Many thanks!

y.ivanov

  • Sr. Member
  • ****
  • Posts: 499
Re: Stringifying a TJSONObject
« Reply #3 on: July 22, 2022, 09:51:53 am »
You can look at FormatJSON function also, it has some handy format options.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

 

TinyPortal © 2005-2018