I want to store JSON attributes in a dict or list whatever will be the best option to store it. The JSON looks like this:
{
"@BOOLOP": "and",
"@SEQ": "0",
"@TYPE": "0",
"FRAGMENT": {
"@FUNC1": "value",
"@FUNC2": "literal",
"@OP": "<",
"@PROP1": "PB:FeederSpeed",
"@PROP2": "0",
},
"BOOLOP": {
"@BOOLOP": "or",
"FRAGMENT": [
{
"@FUNC1": "value",
"@FUNC2": "literal",
"@OP": "=",
"@PROP1": "PB:CPProdSelected",
"@PROP2": "1000",
}
]
}
}
Basically the format of this JSON is that is will have a BOOLOP attibs then a FRAGMENT key (depends) followed by n no. of BOOLOP as Keys.
The point where I am strugling is how to store it in a suitable data structure so that it is easy to perform operations on.
For example , I need to perform operations on FRAGMENT
key but for that I need to check if it has all the conditions meeting or not. Like the @BOOLOP
is and
or or
and as there are multiple BOOLOP
key inside key it is difficult to perform operations upon.
I came this far by extracting the part of JSON I need from a bog JSON but now I am stuck as how to do a recursive call and check if a FRAGMENT
is inside a BOOLOP
.
The JSON I have posted is only a sample on the original file could have n number of @BOOLOP but I can figure that part out after I have my first sample in place.
EDIT