This is my json …
using javascript .. i want to output just the name of the root in this case services
then traverse through the individual elements in the array
{
services: {
46: {
servicetypeid: "27",
serviceid: "51",
servicename: "Parking",
description: "Parking Related Payments",
optioncode: [],
inputid: [],
price: [],
categoryidentifier: []
},
47: {
servicetypeid: "27",
serviceid: "52",
servicename: "Markets",
description: "Markets Related Payments",
optioncode: [],
inputid: [],
price: [],
categoryidentifier: []
},
48: {
servicetypeid: "27",
serviceid: "53",
servicename: "PSV",
description: "Public Service Vehicles",
optioncode: [],
inputid: [],
price: [],
categoryidentifier: []
}
}
}
That’s not JSON format data, you can loop thru the object:
To get the root key, you could do:
And to loop thru all the items: