CatchJSON()

Syntax

Result = CatchJSON(#JSON, *Buffer, Size [, Flags])
Description
Parse JSON data from a memory buffer. The contents of the memory buffer are expected to be encoded in UTF-8 format. The JSONValue() function can be used to access the contained JSON value(s) after parsing.

Parameters

#JSON A number to identify the new JSON. #PB_Any can be used to auto-generate this number.
*Buffer A readable memory location.
Length Length (in bytes) of the memory location.
Flags (optional) If set to #PB_JSON_NoCase, the JSON data will be parsed case insensitive. The default is to be case sensitive.

Return value

Nonzero if the JSON data was parsed correctly, zero otherwise. If #PB_Any was used for the #JSON parameter then the generated number is returned on success.

Remarks

In case of an error, the JSONErrorMessage(), JSONErrorLine() and JSONErrorPosition() functions can be used to get more information about the error.

To parse JSON data directly from a string, the ParseJSON() function can be used instead.

JSON is a case sensitive data format. However, in some situations, such as deserializing structures with ExtractJSONStructure() or similar commands it may be useful to treat JSON objects as case insensitive. The #PB_JSON_NoCase flag causes all member related functions to treat keys in this object as case insensitive.

See Also

CreateJSON(), ParseJSON(), LoadJSON(), JSONValue(), FreeJSON(), JSONErrorMessage(), JSONErrorLine(), JSONErrorPosition(), ExportJSON()

Supported OS

All

<- AddJSONMember() - Json Index - ClearJSONElements() ->