I'm new to javascript and i want to count the values of this json string:
{
"files": [
{
"name": "doc1.pdf",
"title": "networking",
"path": "mfpreader.comze.com\/files\/doc1.pdf"
},
{
"name": "doc2.pdf",
"title": "Armoogum",
"path": "mfpreader.comze.com\/files\/doc2.pdf"
}
]
}
the json is saved in the res.responseJSON.data.
here is the code i tried:
$("#demo").html(JSON.stringify(res.responseJSON.data));
var jsonObject = JSON.parse(res.responseJSON.data);
var propertyNames = Object.keys(jsonObject);
alert("There are "+propertyNames.length+" properties in the object");
The value is get is 1. It should be 2 since we have 2 documents.
can i have some please. Thanks