Search

User Manual

GETTING STARTED


MODULES AND PLATFORM


APPENDIX


TUTORIALS & HELPFUL TRICKS


STRATEGIC PARTNER LINKS

Sepasoft - MES Modules
Cirrus Link - MQTT Modules

RESOURCES

Inductive University
Ignition Demo Project
Knowledge Base Articles
Forum
IA Support
SDK Documentation
SDK Examples

ALL USER MANUAL VERSIONS

Ignition 8.1
Ignition 7.9
Ignition 7.8

Deprecated Pages

Employees

Sign In

Skip to end of metadata
Go to start of metadata

This function is used in Python Scripting.

Description

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

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

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 - Optional parameter. The number of spaces to add to each level of indentation for prettyprinting.

  • Returns

String - The encoded JSON string.

  • Scope

Gateway, Vision Client, Perspective Session

JSON to Python Mapping

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

Python TypeMapped JSON Type
List or TupleArray
IntegerInteger
Nonenull
True/False (boolean)true/false (boolean)
DictionaryObject
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)
Keywords

system util jsonEncode, util.jsonEncode

  • No labels