Xbasic

a5_json_populateArray Function

This function is obsolete. Use json_parse() instead.

Syntax

a5_json_populateArray(arr as P, txt as C)

Arguments

arrPointer

Array to populate with data.

txtCharacter

String of JSON data.

Description

Takes an array of JSON objects and populates an Xbasic property array.

txt = <<%txt%
[
{firstname: 'Fred', lastname: 'Smith', married: true, kids: 2} ,
{firstname: 'richard', lastname: 'smith'}
]
%txt%

dim arr[0] as p
a5_json_populateArray(arr,txt)

?arr.size() 
= 2

?arr[1] 
= firstname = "Fred"
kids = 2
lastname = "Smith"
married = .T.

The a5_json_populateArray() is obsolete. Instead, the json_parse() function should be used to populate an Xbasic property array with JSON data. The example shown above can be rewritten using json_parse() as follows:

txt = <<%txt%
[
{firstname: 'Fred', lastname: 'Smith', married: true, kids: 2} ,
{firstname: 'richard', lastname: 'smith'}
]
%txt%

dim arr as p
arr = json_parse(txt)

? arr.size()
= 2

? arr[1]
= firstname = "Fred"
kids = 2
lastname = "Smith"
married = .T.

See Also