ParseJSON()

Syntax

Result = ParseJSON(#JSON, Input$ [, Flags])
Description
Parse JSON data from a string. 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.
Input$ The string containing the JSON data to parse.
Flags (optional) Not used.

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.

JSON is a case sensitive data format.

Example

  If ParseJSON(0, "[1, 2, 3, 4, 5]")    
    For i = 0 To JSONArraySize(JSONValue(0)) - 1
      Debug GetJSONInteger(GetJSONElement(JSONValue(0), i))
    Next i
  Else
    JSONErrorMessage()
  EndIf

See Also

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

Supported OS

All

<- NextJSONMember() - Json Index - RemoveJSONElement() ->