I have the following line in a JavaScript variable:
my_Variable = "{"Domini":[{"cod_domini":"1","nom_domini":"Sant Esteve de Palautordera"},{"cod_domini":"2","nom_domini":"Parc Natural del Montseny"},{"cod_domini":"5","nom_domini":"Sant Pere de Vilamajor"},{"cod_domini":"6","nom_domini":"Santa Maria i Mosqueroles"}]}"
I need to remove the root at the top of the Domini string so that the resulting string looks like this:
my_Variable = [{"cod_domini":"1","nom_domini":"Sant Esteve de Palautordera"},{"cod_domini":"2","nom_domini":"Parc Natural del Montseny"},{"cod_domini":"5","nom_domini":"Sant Pere de Vilamajor"},{"cod_domini":"6","nom_domini":"Santa Maria i Mosqueroles"}]
I tried JSON.parse() JSON into an object using the JSON.parse() function, and it works, but then I donβt know how to extract the data and process it to create a new JSON without root.
Should I use some kind of loop?
source share