AirborneFluff
New Coder
I have a JSON file, which I convert into an object. This JSON contains multiple items, with multiple tags...
(this is a shorted version for simplicity)
[CODE title="JSON file"][
{"msgID":"879858831960727592","id":"1"},
{"msgID":"879858831960727592","id":"2"}
][/CODE]
I parse this as follows
With the resulting object as 'trials'
Then when I go to find a 'trial' within this object using
I get the following result, which seems perfect!
However, if I try to use a value within it I get the result 'undefined'
Any help would be greatly appreciated!
(this is a shorted version for simplicity)
[CODE title="JSON file"][
{"msgID":"879858831960727592","id":"1"},
{"msgID":"879858831960727592","id":"2"}
][/CODE]
I parse this as follows
Code:
fs.readFile('trials.json', 'utf8', (err, data) => {
if (err) {
console.error(err)
return
}
trials = JSON.parse(data)
})
Then when I go to find a 'trial' within this object using
Code:
const curTrial = trials.filter(trial => trial.id === '1')
console.log(curTrial)
Code:
[
{
msgID: '879858831960727592',
id: '1'
}
]
Code:
console.log(curTrial.id)