There’s a lightweight and flexible command-line JSON processor called jq. It has wide range of capabilites but something that I came across lately and is quite useful for me is printing out the length of a JSON object.

cat testjson.json | jq '. | length'