Hello community,
i have a json file, with a structure like this:
{
"106" : {
"id54011" : [
{
"partno1" : "16690617"
},
{
"partno2" : "5899180"
}
],
"parts" : [
"0899180",
"16920617"
],
"id5632" : [
{
"partno1" : "090699180"
}
]
},
"560" : {
"id9452" : [
{
"partno2" : "1569855"
}
],
"parts" : [
"03653624",
"15899855"
],
"id578" : [
{
"partno3" : "0366393624"
},
{
"partno4" : "0363213624"
}
]
}
}
I need to split this json, into files, like this:
each json file, will consist of one object. 000106.json, and 000560.json.
(all names, must gave 6 digits, so zeros must be added)
I have tried to use eval for this, but no luck up to now...
expected output: json file 1, named 000106.json:
{
"106" : {
"id54011" : [
{
"partno1" : "16690617"
},
{
"partno2" : "5899180"
}
],
"parts" : [
"0899180",
"16920617"
],
"id5632" : [
{
"partno1" : "090699180"
}
]
}
and json file 2, named 000560.json:
{
"560" : {
"id9452" : [
{
"partno2" : "1569855"
}
],
"parts" : [
"03653624",
"15899855"
],
"id578" : [
{
"partno3" : "0366393624"
},
{
"partno4" : "0363213624"
}
]
}
How would you handle this?