I received the below JSON and having difficulty retrieving the value of jersey_num.
const json = [{
$: {
Type: "first_name"
},
_: "Evan"
}, {
$: {
Type: "last_name"
},
_: "Ferguson"
}, {
$: {
Type: "birth_date"
},
_: "2004-10-19"
}, {
$: {
Type: "weight"
},
_: "Unknown"
}, {
$: {
Type: "height"
},
_: "Unknown"
}, {
$: {
Type: "jersey_num"
},
_: "28"
}, {
$: {
Type: "real_position"
},
_: "Striker"
}, {
$: {
Type: "real_position_side"
},
_: "Centre"
}, {
$: {
Type: "join_date"
},
_: "2021-08-23"
}, {
$: {
Type: "country"
},
_: "Republic of Ireland"
}]
I tried using the below code but received undefined
const jersey = Object.entries(json).find(([, e]) => Object.values(e).includes('jersey_num'))
console.log(jersey)
I'm pretty sure there is something wrong with the above code. Hope someone can help and guide me on how to retrieving the jersey_num value
EDIT
- Edited the JSON object to the proper format
- The value that I want to retrieve is '28' as in Type: "jersey_num"