[
{
"B4": 14,
"B5": 12
},
{
"B4": 58,
"B5": 54
},
{
"B4": 26,
"B5": 65
}
]
I want to create index ID in my uploaded json file. The json file look like as in the image. I want it to be like the following:
[
1: {
"B4": 14,
"B5": 12
},
2: {
"B4": 58,
"B5": 54
},
3: {
"B4": 26,
"B5": 65
}
]
It’s just to do some calculations for each set and display the results.
2
Answers
Import your JSON file, extract each element and add it to a dictionary with its key as index. Convert the dictionary to a JSON object and write it on to a JSON file.
Here is the sample code below:
Output:
The list you shared as output is not valid as list cannot be a key value pair. Did you mean this – a dict of dicts?
To get that –