The code you can use to parse this simple structure is as follows:
Code
JSONReader = New JSONReader();
JSONReader.OpenFile("FileName");
Employees = ReadJSON(JSONReader);
JSONReader.Close();
For Each Employee In Employees Do
// Process employee data
EmployeeName = Employee.name;
EmployeeSurname = Employee.surname;
EmployeeAge = Employee.age;
EndDo;
Also, pay attention to the description of the ReadJSON() global context method, which is available in Syntax Assistant.
Type: String. A string, containing text in JSON format. Description:
Defines the row containing JSON text to be read by the given object. If JSON has already been read from another file or rows before this method is called up, the reading will stop and the object initializes for reading from the row shown.
Availability:
Thin client, Mobile client, server, thick client, external connection, Mobile application (client), Mobile application (server). Example:
JSONReader = New JSONReader; JSONReader.SetString("{}");
Actually i tried "SetString", but it did not work... I solved by writing an algorithm...
Code
a = StrSplit(res,"""");
y = 0;
z = 0;
array = new array;
For Each x in a Do
if Not x = "," then
if x = "{" then
y = 1;
elsif x = ":{" then
y = 2;
elsif x = "}," then
if z = 0 then
for i = 0 to array.Count()-1 do
b = "a" + String(i);
VT.Columns.Add(b);
EndDo;
z = 1;
endif;
Row = VT.Add();
for i = 0 to (array.Count()-1) do
Row.Set(i,array[i]);
enddo;
array.Clear();
y = 3;
elsif x = "}}" then
Row = VT.Add();
for i = 0 to (array.Count()-1) do
Row.Set(i,array[i]);
enddo;
array.Clear();
y = 4;
endif;
if y = 1 AND Not x = "{" AND Not x = ":" then
array.Add(x);
elsif y = 2 AND Not x = ":{" AND Not x = ":" then
array.Add(x);
elsif y = 3 AND Not x = "}," then
array.Add(x);
elsif y = 4 AND Not x = "}}" then
endif;
endif;
{CommonModule.Firebase.Module(134)}: Error calling context method (ReadJSON) JsonStructure = ReadJSON(JSONReader ); , reason: Invalid property name "7 DNEI" is encountered when reading JSON data to a Structure object
, reason: Invalid property name "7 DNEI" is encountered when reading JSON data to a Structure object