JSON to tabular form

I am new to Ignition Vision, and am trying to get my data in the form of a table. I am importing the data into the table through an OPC tag {[SDFac]FML20/0.value}["Name"] , and am getting the output:

[
        {
            "M_Funk": 11,
            "M_VKE": 1,
            "M_soll": 10
        },
        {
            "M_Funk": 34,
            "M_VKE": 23,
            "M_soll": 150
        },
        {
            "M_Funk": 4,
            "M_VKE": 13,
            "M_soll": 100
        },
        {
            "M_Funk": 16,
            "M_VKE": 1,
            "M_soll": 40
        },
        {
            "M_Funk": 15,
            "M_VKE": 16,
            "M_soll": 80
        },
        {
            "M_Funk": 16,
            "M_VKE": 2,
            "M_soll": 460
        },
        {
            "M_Funk": 1,
            "M_VKE": 1,
            "M_soll": 10
        },
        {
            "M_Funk": 4,
            "M_VKE": 1,
            "M_soll": 1
        },
        {
            "M_Funk": 16,
            "M_VKE": 1,
            "M_soll": 5
        },
        {
            "M_Funk": 18,
            "M_VKE": 1,
            "M_soll": 4
        },
        {
            "M_Funk": 19,
            "M_VKE": 2,
            "M_soll": 630
        },....]

on my table(in form of text).

I want to show this data in form of a table in Vision. Any help would be appricieted.

have you tried system.dataset.toDataSet(dataset)

def json_to_dataset(data):
	if not data:
		return None
	headers = data[0].keys()
	return system.dataset.toDataSet(
		headers,
		[
			[row[h] for h in headers]
			for row in data
		]
	)

Put this is your library script, then on on your table's data put an expression binding calling this function with your raw data.

runScript(
    'your_lib.json_to_dataset', 0,
    {raw_data}
)
1 Like