Calling convention: CIP_JSON_TryGetValueDef(JSONObjectPointer: NativeInt, "TokenPath": String, "ValueType": String, OutValue: Variant, DefaultValue: Variant): Boolean
Description: Tries to read and convert a JSON value. OutValue receives the converted value on success and DefaultValue otherwise.
Parameters:
JSONObjectPointer = Pointer to a managed JSON value.
TokenPath = Path of the requested value.
ValueType = STRING, INTEGER, NUMBER, DOUBLE, ARRAY or OBJECT.
OutValue = Variable that receives the converted value or DefaultValue.
DefaultValue = Fallback value.
Returns: Boolean: True when lookup and conversion succeed; False otherwise. NULL or 0 pointers return False and leave DefaultValue in OutValue; an invalid nonzero pointer raises an exception.
Availability: Default.
Example:
try
JSONObj := CIP_JSON_CreateObject("{""name"":""John""}");
if CIP_JSON_TryGetValueDef(JSONObj, "name", "STRING", WorkStr, "DefaultValue") then begin
ShowMessage("Found: " + VarToStr(WorkStr));
end else begin
ShowMessage("Not found: " + VarToStr(WorkStr));
end;
finally
CIP_JSON_FreeObject(JSONObj);
end;