I am having json file which around 600MB. The structure of the json file is,
[
{
"metadata":{
"batchSize":100,
"totalRecords":"1000",
"batchIndex":1
},
"notificationData":[
{
"brandId":"A",
"sourceUniqueId":"12345",
"contentType":"PDF",
"transactionId":"cABCD",
"batchId":"ABC_1",
}
]
},
{
"metadata":{
"batchSize":100,
"totalRecords":"1000",
"batchIndex":2
},
"notificationData":[
{
"brandId":"B",
"sourceUniqueId":"789",
"contentType":"PDF1",
"transactionId":"XYZ",
"batchId":"XYZ_1",
}
]
}
]
Now, Output I want the notificationData
array of provided batchIndex
. I am able to find specific batchIndex
But how to get notificationData
of that batchIndex
. BatchIndex
is unique. And after getting notificationData
stops the execution. No need to parse complete file.
f = open('batchIndex.json')
data = ijson.items(f,'item.metadata')
jsons = (o for o in data if o['batchIndex'] == input_batchIndex)
for j in jsons:
print(j)