Function to obtain a text value of a key from a JSON object.

 

Syntax

function JSONGetString(sJSON, sKey: string; var sValue: string): integer;

 

Parameters and return values

Parameter

Type

Value

sJSON

string

JSON object as a text string;

sKey

string

required key name;

sValue

var string

key value, if available.

 

Function result

0

no errors;

1

JSON parsing error;

2

key not found.

 

Example


var
  s, sUserName: string;
begin
  s := '{"User1" : "Jack Nicolson", "User2" : "Isaac Newton"}';
  sUserName := '';
 
  JSONGetString(s, 'User2', sUserName);
  
  mLogScript(sUserName, 'TEST')
end.


Script work result

[21:35:18] (Log "test"): [TEST] Isaac Newton

 

See also

mLogScript

Created with the Personal Edition of HelpNDoc: Converting Word Documents to eBooks: A Step-by-Step Guide with HelpNDoc