Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
// Create the root object, which we'll call employees
If SRP_Json(EmployeesHandle, "New") then
   
   // Create a new array
   If SRP_Json(EmployeeArrayHandle, "New", "ARRAYArray") then
       
       // Add the first employee
       If SRP_Json(SingleEmployeeHandle, "New") then
           SRP_Json(SingleEmployeeHandle, "SetValue", "firstName", "John")
           SRP_Json(SingleEmployeeHandle, "SetValue", "lastName", "Doe")
           SRP_Json(EmployeeArrayHandle, "Add", SingleEmployeeHandle)
           SRP_Json(SingleEmployeeHandle, "Release")
       end
       
       // Add the second employee
       If SRP_Json(SingleEmployeeHandle, "New") then
           SRP_Json(SingleEmployeeHandle, "SetValue", "firstName", "Anna")
           SRP_Json(SingleEmployeeHandle, "SetValue", "lastName", "Smith")
           SRP_Json(EmployeeArrayHandle, "Add", SingleEmployeeHandle)
           SRP_Json(SingleEmployeeHandle, "Release")
       end
       
       // Add the third employee
       If SRP_Json(SingleEmployeeHandle, "New") then
           SRP_Json(SingleEmployeeHandle, "SetValue", "firstName", "Peter")
           SRP_Json(SingleEmployeeHandle, "SetValue", "lastName", "Jones")
           SRP_Json(EmployeeArrayHandle, "Add", SingleEmployeeHandle)
           SRP_Json(SingleEmployeeHandle, "Release")
       end
       
       // Now add the array as a member of the root object
       SRP_Json(EmployeesHandle, "Set", "employees", EmployeeArrayHandle)
       
       // All done with the array object
       SRP_Json(EmployeeArrayHandle, "Release")
   
   end
   
   // Now get the actual JSON
   SampleJSON = SRP_Json(EmployeesHandle, "Stringify", "STYLED")
   
   // All done with the root object
   SRP_Json(EmployeesHandle, "Release")
   
end

...