I'm having trouble getting a specific value from a JSON object.
My program queries wolframalpha which returns an object "result" using the following code:
var wolfram = require('wolfram').createClient("[CENSORED]")
wolfram.query("integrate 2x", function(err, result) {
if(err) throw err
console.log("Result: %j", result)
})
It returns the following JSON:
[
{
"subpods":
[{
"title":"",
"value":" integral 2 x dx = x^2+constant",
"image":"http://www5a.wolframalpha.com/Calculate/MSP/MSP36002050fgg595dgib5a000031a456025754352g?MSPStoreType=image/gif&s=59"
}],
"primary":true
},
{
"subpods": [{
"title":"",
"value":"",
"image":"http://www5a.wolframalpha.com/Calculate/MSP/MSP36012050fgg595dgib5a000055e24iecig9cc4ga?MSPStoreType=image/gif&s=59"
}],
"primary":false
}
]
I'm trying to get "value" from the first subpod. I tried:
var newResults = result.subpods[0].value;
but this gave me an error:
TypeError: Cannot read property '0' of undefined
I've been trying different combinations for at least the last hour. Please help!
Thank you for your time,
Bobbyg