Raj Nepali Raj Nepali - 1 year ago 134
JSON Question

how to remove only key from json object?

i have following json string.

{"Local People":{"label":"Local People","data":1},"Student":{"label":"Student","data":1}}

i want it to be formatted in following format

"label" : "Student",
"data" : 1
"label" : "Student",
"data" : 1

i have tried it many times but unable to change. please help.

Answer Source

After you have parsed the string with JSON.parse, you could take the keys of the object and iterate over the properties for a new array with the items.

var JSONstring='{ "Local People": { "label": "Local People", "data": 1 }, "Student": { "label": "Student", "data": 1 } }'
    object = JSON.parse(JSONstring),
    array = Object.keys(object).map(function(k) {
        return object[k];


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download