6:27 am

February 2, 2017

Hello,
I am new to thingspeak.I am trying to Parse the Json values of a channel.I tried for the description and metadata and got it.Now i am trying to get the api_keys but i am unable to do it.I am adding the code that i used to parse.with this below code i am getting the error (Uncaught SyntaxError: Unexpected token [ in JSON at positon 1).Can anyone help me how to Parse JSON api_key values,Thankyou.
CODE:-
var obj,ak ;
ak="";
for (var i=0; i<json.length; i++) {
obj = json[i];
if (obj == null || obj == "") {
window.alert("
The "+(i+1)+"th object is NULL/BLANK.");
} else {
if (obj.id == did) {
if (obj.api_keys == null || obj.api_keys == "") {
window.alert("
The api_keys portion of "+(i+1)+"th object is NULL/BLANK.");
} else {
ak = JSON.parse("{" + obj.api_keys + "}");
console.log("
The deails of "+(i+1)+"th Object are :
Apikey : " + ak.api_key + "
WriteFlag : " + ak.write_flag );
}
11:11 pm


Top
January 30, 2014

Did you try to print the whole json object and each array member in turn using console.log()?
I often use http://jsonlint.com/ to check if json is properly formatted or not.
12:17 am

September 6, 2017

I use this tool to check JSON format: JSON Formatter
Most Users Ever Online: 114
Currently Online:
15 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 261
Vinod: 196
piajola: 85
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 5703
Moderators: 0
Admins: 2
Forum Stats:
Groups: 4
Forums: 17
Topics: 1313
Posts: 4565
Newest Members:
harriettlf60, ShaToow, Aleftinfenny, DiaBentee, hugo11dom@gmail.com, Pisaruk530Administrators: Hans: 387, lee: 457