Ideal way to display objects on a screen

Here is a way to do it without using an expression. @PGriffith can comment if there is anything bad here, but avoids the use of the other library that can’t be imported.

def toDict(perspective_object):
	"""Formats a perspective object as Dict
	
	Adapted from http://forum.inductiveautomation.com/t/ideal-way-to-display-objects-on-a-screen/41575

	Args:
		perspective_object: A perspective property object
	"""
	from com.inductiveautomation.ignition.common import TypeUtilities
	
	# Convert the Perspective property object to Gson and back to a Py Object
	return TypeUtilities.gsonToPy(TypeUtilities.pyToGson(perspective_object))
	
	
def toMarkdown(perspective_object, indent=3):
		"""Formats a perspective object as Markdown
	
		Args:
			perspective_object: A perspective property object
		"""
		from json import dumps
		json_string = dumps(toDict(perspective_object), indent=indent)
		return "```\n{}\n```".format(json_string)
4 Likes