How to do JSON parsing to get api_keys | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
How to do JSON parsing to get api_keys
No permission to create posts
February 2, 2017
6:27 am
Avatar
AnushaPoola
New Member
Members
Forum Posts: 1
Member Since:
February 2, 2017
sp_UserOfflineSmall Offline

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 );
}

February 11, 2017
11:11 pm
Avatar
rw950431

Top
Members
Forum Posts: 261
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

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.

September 6, 2017
12:17 am
Avatar
zoey7
New Member
Members
Forum Posts: 2
Member Since:
September 6, 2017
sp_UserOfflineSmall Offline

I use this tool to check JSON format: JSON Formatter

October 21, 2017
11:57 pm
Avatar
ezmaintain
New Member
Members
Forum Posts: 1
Member Since:
October 21, 2017
sp_UserOfflineSmall Offline

Yes JSON Formatter is good tool

Forum Timezone: America/New_York

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, Pisaruk530

Administrators: Hans: 387, lee: 457