Thank you for your hints.
If $r is a hash ref, then $$r is a hash, then $$r{$k} is a value in that hash. This is of course the matter of style only.
Yes -- I'm doing deep recursion. Example of use below:
# echo '{"alfa": { "beta": null, "teata": null, "adfa": null, "n": {}, + "ixi": {}, "marr": [1, 2] } }' | ./tidyup_json { "alfa" : { "marr" : [ 1, 2 ] } } # echo '{"alfa": { "beta": null, "teata": null, "adfa": null, "n": {}, + "ixi": {}, "marr": [null, null] } }' | ./tidyup_json null # echo '{"alfa": { "beta": null, "teata": null, "adfa": null, "n": {}, + "ixi": {}, "marr": [null, null, 3] } }' | ./tidyup_json { "alfa" : { "marr" : [ 3 ] } } # echo '{"alfa": { "beta": { "gamma" : 3 } } }' | ./tidyup_json { "alfa" : { "beta" : { "gamma" : 3 } } } # echo '{"alfa": { "beta": { "gamma" : {} } } }' | ./tidyup_json null # echo '{"alfa": { "beta": { "gamma" : {} }, "nth": 9 } }' | ./tidyup_ +json { "alfa" : { "nth" : 9 } }
In reply to Re: Tidy up json from nulls, empty arrays and hashes
by leszekdubiel
in thread Tidy up json from nulls, empty arrays and hashes
by leszekdubiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |