Scripting function takes a dict however the received datatype is DotReferenceJythonMap

I am using a Perspective onActionPerformed Script to open a popup:

system.perspective.openPopup('def', 'facility/addTask/confirmation', params = {'new_dict': new_dict}, modal = True)

In the gateway logger I have verified that new_dict being put into the function call is of type:

new_dict is: <type 'dict'>

In the popup I have a parameter called new_dict and the first thing I do is use a script transform to display the datatype of the parameter. I get the following datatype:

class com.inductiveautomation.perspective.gateway.script.DotReferenceJythonMap

How can I convert this back to a jython dictionary? Or how can I loop through and unpack my dictionary values from a JythonMap?

Try supplying it to the dict() constructor. (This works only for single-level mapping objects.)

Perspective converts any jython dictionaries and/or lists (in any nested combination) to Perspective property objects, dropping the pythonic origin. Then when delivered back to jython elsewhere, Perspective places them in a wrapper object that supports attribute referencing.


The JythonMap behaves the same as a dict for most purposes.

If you look at the reference above, you'll see it supports all the usual methods of a python dict, including keys(), items(), etc.

On closer inspection, there is also a toDict() method that presumably will explicitly return the dict inside the wrapper. However, you should never really need it in everyday usage.

See also the discussion here:

EDIT: updated javadocs reference to latest version (as of this posting)