I need to remove parts of a JSON, but I do not know how I can do it.
I'm converting the same to CSV, and when I convert the structure it gets all weird
Here is the print explaining better, which is marked in black, I need to remove it and the one in red I need to keep.
Here'sjsonforwhatIneedtoconvert:
{"@odata.context":"url requisição",
"value":[
{
"cprq_cert_id":51,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
},
{
"cprq_cert_id":52,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
},
{
"cprq_cert_id":54,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
},
{
"cprq_cert_id":72,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
},
{
"cprq_cert_id":73,
"cprq_object_id":"xxxxxxxxxxxxxxxxxxxx",
"cprq_cert_cert_id":0
}
]
}
And also the python script I use to convert:
import csv
import json
infile = open("nomejson.json","r")
outfile = open("nomecsv.csv","w")
writer = csv.writer(outfile)
for row in json.loads(infile.read()):
writer.writerow(row)