I'm trying to get JSON data from sparkfun using ajax:
var public_key = "someKey";
var jsonData = $.ajax({
url: "https://data.sparkfun.com/output/" + public_key + ".json",
data: { page: 1 },
dataType: "jsonp",
}).done(function (results) {
// loop through results and log temperature to the console
$.each(results, function (index, row) {
console.log(row.1um_data);
})
})
but it's giving me the error:
Uncaught SyntaxError: missing ) after argument list
If I get rid of the number that the key starts with, or put a number elsewhere in the key, it doesn't give an error, so I'm fairly certain it's the number that it's starting with that's throwing it off.
I've tried row[1um_data], but it throws the error: Uncaught SyntaxError: Unexpected identifier.
If I just do console.log(row);
, it shows that there indeed is a field in the JSON labeled '1um_data'.
How do I access JSON data with a key that starts with a number?