Sign in Join
FPDoc Onlineexperiment

GetJSON function

In unit fpJson

Convert JSON string to JSON data structure.

Declaration

pascal
function GetJSON(const JSON: TJSONStringType; 
 const UseUTF8: Boolean=True): TJSONData

Arguments

JSON

The JSON to parse.

UseUTF8

Convert Unicode characters to UTF-8.

Function result

The TJSONData data (tree) represented by JSON.

Description

GetJSON will read the JSON argument (a string or stream that contains a valid JSON data representation) and converts it to native JSON objects. The stream must be positioned on the start of the JSON.

The fpJSON unit does not contain a JSON parser. The jsonparser unit does contain a JSON parser, and must be included once in the project to be able to parse JSON. The jsonparser unit uses the SetJSONParserHandler call to set a callback that is used by GetJSON to parse the data.

If UseUTF8 is set to true, then Unicode characters will be encoded as UTF-8. Otherwise, they are converted to the nearest matching ansi character.

Errors

An exception will be raised if the JSON data stream does not contain valid JSON data.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.