I have a very heavily nested json file with multiple blocks inside it. The following is an excerpt of the file, It has more than 6 levels of nesting like that
{
"title": "main questions",
"type": "static",
"value":
{
"title": "state your name",
"type": "QUESTION",
"locator": "namelocator",
}
}
If anyone can please help me to parse this in a way such that, i can find the title and locator when type = question(because the type may vary across different parts of the file) and that too concurrently(sequential would kill the system considering the scale of the file)
I have been using the following code to get the values of title and locator separately pip install jsonpath(in anaconda terminal)
from jsonpath import JSONPath
import json as js
data = js.load(f)# f is the path to .json file
JSONPath('$.[?(@.type== "QUESTION")].locator').parse(data)
JSONPath('$.[?(@.type== "QUESTION")].title').parse(data)
The problem is: I am getting the list of locators and title, but its all jumbled since there is no way to know the sequence the function parses the file in its been a while since I am stuck with this problem, and the only solution is going across the file to find all type==questions and then looping again to find the locators and titles(which is computationally not really feasible for a huge chunk of files)