RFE: JSON DAT (like the XML DAT)

It would be great to have a DAT that can handle JSON formatted data in the way that the XML DAT works.

yes, once I get my python skillz up to scratch I should be able to make my own but …

Hey Rodney,

yeah - JSON in python is quite simple as once decoded it is treated as a dictionary.

Here is a simple example of a JSON file and it’s decoding script:

{
   "myObject" : {
      "testArray" : [ "arrayEntry1", 2, "arrayEntry2" ],
      "testInteger" : 1,
      "testString" : "myTest"
   }
}
import json

raw = str(op('jsonRaw')[0,0])
jsonDecode = json.loads(raw)

#get myObject
myObject = jsonDecode['myObject']

#loop through myObject and print key name
print('--- ---\nmyObject keys:')
for i in myObject:
	print(i)

#get array entries
testArray = myObject['testArray']
print('--- ---\ntestArray elements:')
for i in testArray:
	print(i)
	
#get other elements:
print('--- ---\nother elements:')
print('testInteger:',myObject['testInteger'])
print('testString:',myObject['testString'])

As you can see the only thing to make JSON processable in python is the

import json

and

jsonDecode = json.loads(raw)

function. Once you have decoded the JSON via the loads function you access it’s elements like a default dictionary with key / value pairs.

More on JSON de- and encoding can be found here and on dictionaries here

Hope that helps,
cheers
Markus

Thanks Markus, lots to study now! :slight_smile:

rod.