JsonArrayResize Function

Action

Resizes a JSON array. If the specified size is lower than the actual size, the last elements of the JSON array are removed. If the specified size is higher than the actual size, empty elements are added to the end of the JSON array.

Include file

Json.bdh

Syntax

JsonArrayResize( in handle : number,
                 in size   : number ): boolean;
Parameter Description
handle Valid handle to a JSON array
size The new size of the JSON array

Return value

  • true if the size of the JSON array changed
  • false otherwise

Example

transaction TMain
var
  jsonText  : string;
  jsonArray : number;
begin
  jsonArray := JsonParse("[0,1,2,3,4]");
  
  JsonArrayResize(jsonArray, 2);
  JsonToText(jsonArray, jsonText);
  Print("resized array: " + jsonText);
  
  JsonArrayResize(jsonArray, 4);
  JsonToText(jsonArray, jsonText);
  Print("resized array: " + jsonText);

  JsonFree(jsonArray);
end TMain;

Output


resized array: [0,1]
resized array: [0,1,null,null]