#1 2016-02-19 10:10:12

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

JSONDecode of a array of json

Hi,

I would like to decode an array of json, for example this one :  [{"id":"1","nom":"test1.sql","dti":"2016-02-19 09:49:31"},{"id":"2","nom":"test2.sql","dti":"2016-02-19 09:50:12"}]

When I use the JSONDecode function : "JSONDecode(input, ['id'], output);" , I receive only id = 1. My question is simple, how can I receive an array of values.

Thank you


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

#2 2016-02-19 11:36:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,666
Website

Re: JSONDecode of a array of json

As stated by the doc, JSONDecode() expects a JSON object, not a JSON array.

Either use
- TDocVariant
- a TSynPersistent class + a T*ObjArray
- a record + a dynamic array

The easiest is TDocVariant.

Offline

Board footer

Powered by FluxBB