jsonDeleteValue (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

2.10.00


jsonDeleteValue removes specified element from a JSON object or array.

 

When working on a JSON object, set the key parameter to the name of the value to remove.

When working on a JSON array, idx must be set to the index of the element to remove.

 

 

 

Input:

o : SYSHANDLE

A handle to the JSON array or object to remove the element from.

 

idx : INT (Default -1)

Index to use when working on a JSON array.

Leave at -1 when working on a JSON object.

 

key : STRING

The name of the value when working on a JSON object.

 

 

Returns: INT

1

- Success.

0

- Function is not supported.

-1

- Invalid key

-2

- Element not found.

-3

- Invalid handle.

-4

- The type of o does not match the expected type.

-5

- Array index is outside array.

 

 

Declaration:

FUNCTION jsonDeleteValue : INT;
VAR_INPUT
  o     : SYSHANDLE;
  idx   : INT := -1;
  key   : STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc  : INT;
  arr : SYSHANDLE;
END_VAR;
 
BEGIN
  ...
  // Delete element from array
  rc := jsonDeleteValue(o := arr, idx := 0);
  ...
END;
 
END_PROGRAM;