split a huge json file in separate per object files

[email protected] (Marios lyberak) Fri, 10 Mar 2017 15:57:40 +0200
Newsgroups perl.perl4lib
Message-ID <CAJ0S-uZikoyQwDgutB4WeDuR5fHfBwcSynuAkFmPHGumYFZ0Pw@mail.gmail.com>
--f403045cf29eb8ca1c054a60bed4
Content-Type: text/plain; charset=UTF-8

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?

--f403045cf29eb8ca1c054a60bed4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: base64

PGRpdiBkaXI9Imx0ciI+SGVsbG8gY29tbXVuaXR5LDxicj48ZGl2Pjxicj5pIGhhdmUgYSBqc29u
IGZpbGUsIHdpdGggYSBzdHJ1Y3R1cmUgbGlrZSB0aGlzOjxicj48YnI+ezxicj4mcXVvdDsxMDYm
cXVvdDsg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