How can one in Ruby "generically" count the number of objects for JSONs in the below formats (rooted, unrooted)? By generically, I mean the elements may be different ("title" for instance by be called something else).
without root:
{
[
{ "title": "Post 1", "body": "Hello!" },
{ "title": "Post 2", "body": "Goodbye!" }
]
}
root wrapped:
{
"posts":
[
{ "title": "Post 1", "body": "Hello!" },
{ "title": "Post 2", "body": "Goodbye!" }
]
}