Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Scripting_function


Panel
titleDescription

Takes a Python object such as a list or dictionary and converts into a JSON string.

Panel
titleClient Permission Restrictions

This scripting function has no Client Permission restrictions.

Panel
titleSyntax

system.util.jsonEncode(pyObj, [indentFactor])

  • Parameters

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

Integer indentFactor - The number of spaces to add to each level of indentation for prettyprinting. [optional]

  • Returns

String - The encoded JSON string.

  • Scope

Gateway, Vision Client, Perspective Session

Panel
titleJSON to Python Mapping

The table below lists possible Python types, and how they map to JSON objects. 

Python TypeMapped JSON Type
Boolean (True/False)Boolean (true/false)
StringString
Number (Float, Integer)Numeric
Nonenull
SequenceArray
StringDictionaryStringObject
Panel
titleCode Examples
Code Block
languagepy
titleCode 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)
Panel
titleKeywords

system util jsonEncode, util.jsonEncode