Function to obtain the Boolean value of a key from a JSON object.

 

Syntax

function JSONGetBoolean(sJSON, sKey: string; var bValue: boolean): integer;

 

Parameters and return values

Parameter

Type

Value

sJSON

string

JSON object as a text string;

sKey

string

the required key name;

bValue

var boolean

key value, if available.

 

Function result

0

no errors;

1

JSON parsing error;

2

key not found.

 

Example


var
  s: string;
  b: boolean;
begin
  s := '{"Alexander" : true, "Clarissa" : false}';
    if JSONGetBoolean(s, 'Alexander', b) = 0 then begin
      if b then mLogScript('Graduated specialist', 'TEST')
        else mLogScript('Student', 'TEST');
    end else mLogScript('Key not found or parsing error', 'TEST');
end.


Script work result

[14:24:52] (Log "test2"): [TEST] Graduated specialist

 

See also

mLogScript