Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
for example:
var text =
{"employees":[
{"firstName":"John", "lastName":"Doe", "Age":"24", "Gender":"M"},
{"firstName":"Anna", "lastName":"Smith", "Age":"25", "Gender":"F"},
{"firstName":"Peter", "lastName":"Jones", "Age":"24", "Gender":"M"},
{"firstName":"Aditya", "lastName":"Kumar", "Age":"25", "Gender":"M"},
{"firstName":"Shashank", "lastName":"Rai", "Age":"24", "Gender":"M"},
{"firstName":"Harshit", "lastName":"Chowdhary", "Age":"24", "Gender":"M"},
{"firstName":"Reetam", "lastName":"Kansabanik", "Age":"26", "Gender":"M"},
{"firstName":"Priyanka", "lastName":"Kumari", "Age":"20", "Gender":"F"},
{"firstName":"Nidhi", "lastName":"Tiwari", "Age":"22", "Gender":"F"},
{"firstName":"Priyanshu", "lastName":"Mehta", "Age":"23", "Gender":"M"},
{"firstName":"Preeti", "lastName":"Gupta", "Age":"24", "Gender":"F"},
{"firstName":"Virat", "lastName":"Kohli", "Age":"28", "Gender":"M"},
{"firstName":"Mahendra", "lastName":"Dhoni", "Age":"24", "Gender":"M"},
{"firstName":"Harshita", "lastName":"Rai", "Age":"23", "Gender":"F"},
{"firstName":"Ishan", "lastName":"Verma", "Age":"24", "Gender":"M"},
{"firstName":"Moen", "lastName":"Ali", "Age":"24", "Gender":"M"},
{"firstName":"Muktesh", "lastName":"Chandra", "Age":"32", "Gender":"M"},
{"firstName":"Vinod", "lastName":"Patel", "Age":"28", "Gender":"M"}
]}
In the above example we have 18 elements, but how take the length of var text in case of JSON elements in thingworx?
in normal outside thingworx, we use:
Object.keys(text).length;
But this is not working.
Try this. It will do.
var result = text["employees"].length;
Thanks Praveen