I have a nested JSON object in my react-native app which is in the following format, where key names are different but the structure of all values is the same i.e.
{"value": "...", "label": "..."}
{
"name": {
"value": "Doctor Stranger Things",
"label": "Name"
},
"qualification": {
"value": "MBBS",
"label": "Qualification"
},
"specialization": {
"value": "Magic",
"label": "Specialization"
}
}
I have tried using .map() but since I'm new to react-native and ES6 I don't have a good grasp on its usage. The following code which I've tried is not working as expected.
render(){
return(
<View>
{jsonData.map((item) => (
<View>
<Text>{item.value}</Text>
<Text>{item.label}</Text>
</View>
))}
</View>
);
}
Assuming I have stored the JSON object in a variable jsonData, how do i access value and label of each key without having to access each value like jsonData.name.value or jsonData.qualification.value?
PS: This may seem like a duplicate but I want to avoid using multiple for loops for storage and display purposes. And it's kind of different than what I want.