Lazarus

Programming => General => Topic started by: Jvan on September 28, 2020, 11:48:15 pm

Title: JSON Tools: How to loop a JSON?
Post by: Jvan on September 28, 2020, 11:48:15 pm
A loop getting the key and the value of each item, like in php:

Code: Pascal  [Select][+][-]
  1. foreach ($arr1 as $key => $val) {
  2.    ...
  3. }
  4.  

Json Tools: https://www.getlazarus.org/json/
Title: Re: JSON Tools: How to loop a JSON?
Post by: pcurtis on September 29, 2020, 10:50:21 am
Have a look at this

You might need libeay32.dll, ssleay32.dll, synapse (opm) and Jvcllaz (opm)
Title: Re: JSON Tools: How to loop a JSON?
Post by: Jurassic Pork on September 29, 2020, 12:35:21 pm
hello,
simple Getmen's example here (https://forum.lazarus.freepascal.org/index.php/topic,39801.msg274148.html#msg274148).

Friendly, J.P
Title: Re: JSON Tools: How to loop a JSON?
Post by: Okoba on September 29, 2020, 12:56:21 pm
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. uses
  4.   JsonTools;
  5.  
  6. var
  7.   N, C: TJsonNode;
  8. begin
  9.   N := TJsonNode.Create;
  10.   N.Parse('{"X":1,"Y":2}');
  11.   for C in N do
  12.     WriteLn('Name: ', C.Name, ', Value: ', C.Value);
  13.   ReadLn;
  14. end.
Title: Re: JSON Tools: How to loop a JSON?
Post by: Jvan on September 29, 2020, 09:54:27 pm
Thanks!
Title: Re: JSON Tools: How to loop a JSON?
Post by: Okoba on September 29, 2020, 10:46:42 pm
Welcome.
TinyPortal © 2005-2018