system.util.jsonEncode

Description

Takes a Python object such as a list or dict and converts into a json string.

Syntax

system.util. jsonEncode( pyObj )

  • Parameters

PyObject pyObj - The Python object to encode into JSON such as a Python list or dictionary.

  • Returns

String - The encoded JSON string.

  • Scope

All

Syntax

system.util. jsonEncode( pyObj, indentFactor )

  • Parameters

PyObject pyObj - The Python object to encode into JSON such as a Python list or dictionary.

int indentFactor - The number of spaces to add to each level of indentation for prettyprinting

  • Returns

String - The encoded JSON string.

  • Scope

All

Code Examples
Code Snippet
#The following example builds a Python dictionary, and converts it to a JSON string
 
#Build the Python dictionary
employeeDict = {"employees":[{"firstName":"John", "lastName":"Doe"},{"firstName":"Anna", "lastName":"Smith"},{"firstName":"Peter", "lastName":"Jones"}]}
 
#Convert the dictionary and store the resulting JSON string in a variable.
jsonString = system.util.jsonEncode(employeeDict)