JsonSetArrayProperty Function

Action

Replaces the value of a specified property from a JSON object. If the property does not exist in the JSON object, a new property with the specified name and value will be created. If the the property does not contain a JSON array value, nothing happens.

Include file

Json.bdh

Syntax

JsonSetArrayProperty( in handle   : number,
                      in property : string,
                      in value    : number ): boolean;
Parameter Description
handle Valid handle to a JSON object
property Name of the property in the JSON object (case sensitive)
value A handle to the JSON array, which should be the new value of the property

Return value

  • true if value successfully written to property
  • false otherwise

Example

transaction TMain
var
  jsonText   : string;
  jsonObject : number;
  newValue   : number;
begin
  WebParseDataBound(jsonText);
  WebPageUrl("http://mycompany.com/api/jsondata");
  jsonObject := JsonParse(jsonText);
  
  newValue := JsonParse("[0,1,2,3,4]");
  JsonSetArrayProperty(jsonObject, "JsonArrayPropertyName", newValue);

	JsonFree(newValue);
  JsonFree(jsonObject);
end TMain;