Recent

Author Topic: A new design for a JSON Parser  (Read 35435 times)

sysrpl

  • Sr. Member
  • ****
  • Posts: 253
    • Get Lazarus
Re: A new design for a JSON Parser
« Reply #90 on: August 11, 2021, 11:18:23 am »
Another way to add an array of string nodes would be:

Code: Pascal  [Select][+][-]
  1. procedure AppendStrings(Node: TJsonNode; Strings: TStrings);
  2. var
  3.   S: string;
  4. begin
  5.   Node := Node.Add('Strings').AsArray;
  6.   for S in Strings do
  7.     Node.Add.AsString := S;
  8. end;


If Strings contained `apple, banana, cucumber, doughnut` then after using the `AppendStrings` code above Node would at minumum look like:

Code: Text  [Select][+][-]
  1. { "Strings": ["apple", "banana", "cucumber", "doughnut"] }

zoltanleo

  • Sr. Member
  • ****
  • Posts: 365
Re: A new design for a JSON Parser
« Reply #91 on: August 11, 2021, 04:49:07 pm »
Hi sysrpl.

Thank a lot. I try to use it.

Upd: I already wanted to be glad that you have added a new convenient procedure to the module. I was wrong.
I found a workaround a long time ago by following @engkin's advice. I was hoping you would add one more to some useful features.  :-[
« Last Edit: August 11, 2021, 10:38:18 pm by zoltanleo »
Win10 LTSC x64/Deb 11 amd64/Darwin Cocoa (Big Sur):
Lazarus x32/x64 2.3(trunk); FPC 3.3.1 (trunk), FireBird 3.0.7

Sorry for my bad English, I'm using translator ;)

 

TinyPortal © 2005-2018