Recent

Author Topic: JSON Tools: How to loop a JSON?  (Read 344 times)

Jvan

  • Full Member
  • ***
  • Posts: 120
JSON Tools: How to loop a JSON?
« 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/

pcurtis

  • Sr. Member
  • ****
  • Posts: 311
Re: JSON Tools: How to loop a JSON?
« Reply #1 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)
« Last Edit: September 29, 2020, 11:14:37 am by pcurtis »
Windows 10 / Linux Mint 20
Laz 2.10.0
FPC 3.2.0

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 840
Re: JSON Tools: How to loop a JSON?
« Reply #2 on: September 29, 2020, 12:35:21 pm »
hello,
simple Getmen's example here.

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

OkobaPatino

  • Jr. Member
  • **
  • Posts: 94
Re: JSON Tools: How to loop a JSON?
« Reply #3 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.

Jvan

  • Full Member
  • ***
  • Posts: 120
Re: JSON Tools: How to loop a JSON?
« Reply #4 on: September 29, 2020, 09:54:27 pm »
Thanks!

OkobaPatino

  • Jr. Member
  • **
  • Posts: 94
Re: JSON Tools: How to loop a JSON?
« Reply #5 on: September 29, 2020, 10:46:42 pm »
Welcome.

 

TinyPortal © 2005-2018