system.util.jsonDecode

Description

Takes a json String and converts it into a Python object such as a list or a dict. If the input is not valid json, a string is returned.

Syntax

system.util. jsonDecode( jsonString )

  • Parameters

String jsonString - The JSON string to decode into a Python object.

  • Returns

PyObject - The decoded Python object.

  • Scope

All

Code Examples
#The following example reads in a JSON string, and converts the string to a Python object.
#The example attempts to read the JSON string from a text file, but this could easily be modified to read data from a web server.
 
#Read the JSON string
jsonString = system.file.readFileAsString("C:\tmp\\json.txt")
 
#Decode the JSON string and store the results into a variable
obj = system.util.jsonDecode(jsonString)
 
#Do something with the results. The code below prints the datatype of the results to the console.
print type(obj)