[fpc-pascal] Copy TJSonArray to Array
inquiry at greensnakedesign.com
Wed Aug 12 18:45:32 CEST 2015
On 08/12/2015 12:36 AM, Michael Van Canneyt wrote:
> On Wed, 12 Aug 2015, Chris Moody wrote:
>> Hi all,
>> First off thanks to all who have provided help over the past few
>> weeks, I just have one last thing I'm trying to unravel (that I know
>> of currently) and this project should be done.
>> The JSON feed I'm reading will have 2 arrays in it, would it be best
>> to copy these to a normal array and then process the data? Or best to
>> step through the TJSONArray?
> if there is going to be a lot of processing, you might be better off
> copying the data.
> The JSON structure does incur some processing overhead.
>> I'm not sure how to copy a TJSONArray to an Array, I tried: A:=
>> E.Value.AsArray; but that of course did not work.
> A regular loop is simplest:
> MyArray : TMyArray;
> MyJSONArray : TJSONArray;
> i : Integer;
> MyJSONArray:=// Get the array...
> For I:=0 to MyJSONArray.Count-1 do
> // Now work with myarray
> Use the correct property for whatever type the array contains.
Thanks or the feedback. Just to make sure I'm understanding this, here
is some more information, part of the JSON feed I'm working with will
look like this:
My intention was to be able to get the keys under "add" and turn it into
So if I'm understanding this correctly, I have to do something like the
A2:Array of String;
E : TJSONEnum;
// Put JSONData into J
for E in J do
if E.Key = 'add' then
//Somehow copy add from J to A1
// Use your code to copy A1 into A2
Is this the right way of looking at it?
I have checked what is available online and not finding a lot as far as
how to work with JSON, hopefully this will improve. Once I finish this
software, I'd be more than happy to help in donating time for making new
Wiki pages as far as this subject is concerned.
More information about the fpc-pascal