I want to fetch the nested key and manipulates their data.
I have tried 2 methods:
Example 1:
for (let key in the dictionary) {
for (let keys in dictionary[key]) {
console.log(keys)
}
}
Example 2:
for (let key in dictionary) {
for (let k in lng.dictionary[key]["data"]) {
console.log(k)
}
}
In Example 1, I am getting both the keys
name
anddata
.In Example 2,I am getting only a, b, c, d, yes, no, f, hgs, cft, vit. not their values.
But I want to:
Fetch only data.
and manipulate their values like
{"key":"a","value":"some text"},{"key":"b","value":"some text"},{"key":"c","value":"c for"},{},{}
.
here is my Json object
"dictionary" : {
"bar" : {
"name" : "Bar",
"data" : {
"a" : "some text",
"b" : "some text",
"c" : "c for",
"d" : "some text",
"yes" : "true",
"No" : "true",
"f" : "some text"
}
},
"text" : {
"name" : "Text",
"data" : {
"hgs" : "some text",
"cft" : "some text",
"vit" : "some text"
}
}
}