Using JSON string in report: Scripting Data Source Fails

I’m passing a string (JSON) as a parameter to a report, then parsing it into separate data sources.
Example JSON string

"{'ignored': 1511, 'failed': [['style', 1234567], ['style2', 9658234]], 'success': 2531}"

My parsing script fails with error Line 10: list indices must be integers, but I don’t follow. The script works fine in the console.

	jsonStr = data['jsonString']
	
	resultDict = system.util.jsonDecode(jsonStr)
	
	# create dataset from failed items
	header = ['style','serial']
	data = resultDict['failed']
	
	data['failed'] = system.dataset.toDataSet(header,data)  // line 10
    //data['ignored'] = resultDict['ignored']
	//data['success'] = resultDict['success']

You re-assign data to whatever the value for the "failed" key is.

Then you try to pull out a value using "failed" as the key, but you apparently have a list stored in data at this point.

1 Like

Ugh, stupid mistake, I don’t know how I didn’t see the naming clash. Thanks!