Add style and value to json script

Assuming you can’t get a json instead of a dataset (you can select json as a query output for example),
and that there is no built-in function to convert a dataset into a json,
You could do something like this :

return [
	{
		'low_limit': row[0],
		'high_limit': row[1],
		'process_value': {
			'style': {
				'background_color': "#F7901D",
				'classes': "some_class"
			},
			'value': row[3] 
		}
	} for row in system.dataset.toPyDataSet(value)
]

or directly unpack each row:

return [
	{
		'low_limit': low,
		'high_limit': high,
		'process_value': {
			'style': {
				'background_color': "#F7901D",
				'classes': "some_class"
			},
			'value': proc
		}
	} for low, high, proc in system.dataset.toPyDataSet(value)
]
1 Like