Posts

Showing posts from February, 2019

Counting keys in the JSON

Image
1 This is my json var json = { "pages": [{ "name": "page1", "elements": [{ "type": "text", "name": "question1" }, { "type": "text", "name": "question2" }, { "type": "text", "name": "question3" } ] }] }; Now I try to count this json with this code var keyCount = Object.keys(json).length; console.log(keyCount); The output is 1. But all i need is count this { "type": "text", "name": "question1