javascript - How to get single specific values for keys in json structure? -


i doing exercise like:

var jsonres; jsonres = json.stringify(jsonobjectarray); alert(jsonvals); // getting below json structure  jsonres = {     "key01": [10, "key01 description"],     "key02": [false, "it's false value"],     "key03": [null, "testing null"],     "key04": ["tests", "another test value"],     "key05": [[25, 50], "some testing values"] } 

but need like:

jsonres = {     "key01": 10,     "key02": false,     "key03": null,     "key04": "tests",     "key05": [25,50] } 

how can above structure(means need single values, don't need second values/multiple values respective keys) ? please me , in advance.

var jsonres = {     "key01": [10, "key01 description"],     "key02": [false, "it's false value"],     "key03": [null, "testing null"],     "key04": ["tests", "another test value"],     "key05": [[25, 50], "some testing values"] }  for(var key in jsonres){    if(jsonres.hasownproperty(key)){       jsonres[key] = jsonres[key][0];    } }  console.log(jsonres) 

https://jsfiddle.net/xd4nwc0m/


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -