split a huge json file in separate per object files

2017-03-10 Thread Marios lyberak
Hello community, i have a json file, with a structure like this: { "106" : { "id54011" : [ { "partno1" : "16690617" }, { "partno2" : "5899180" } ], "parts" : [ "0899180", "16920617" ], "id5

Re: split a huge json file in separate per object files

2017-03-10 Thread Brad Baxter
#!/usr/bin/perl use strict; use warnings; use JSON; # version 2.90 my $hash = from_json( test_json_string() ); for my $key ( keys %$hash ) { my $filename = sprintf "%.06d.json", $key; my $subhash = $hash->{ $key }; open my $fh, '>', $filename or die "Can't open $filename: $!"; pr