JsonArrayGetFloatElement Function

Action

Retrieves the value of a specified element from a JSON array. If the array element does not exist in the JSON array or the arrayelement does not contain a float value nothing happens.

Include file

Json.bdh

Syntax

JsonArrayGetFloatElement( in handle : number,
                          in index  : number,
                          out value : float ): boolean;
Parameter Description
handle Valid handle to a JSON array
index The index position in the JSON array. Lower bound is zero (0).
value Parameter that contains the value of the specified element

Return value

  • true if element successfully found
  • false otherwise

Example

transaction TMain
var
  jsonText     : string;
  jsonArray, i : number;
  elementValue : float;
begin
  WebParseDataBound(jsonText);
  WebPageUrl("http://mycompany.com/api/jsondata");
  jsonArray := JsonParse(jsonText);
  
  for i := 0 to (JsonGetArrayLength(jsonArray) - 1) do
    JsonArrayGetFloatElement(jsonArray, i, elementValue);
	Print("index: " + string(i) + ", value: " + string(elementValue));
  end;
  
  JsonFree(jsonArray);
end TMain;