0

I want to read below json array.

[{"bus_code":"1103030017","bus_name":"Tony\u0027s Sports Bar \u0026 Grill","first_name":"","last_name":"","email":"[email protected]","phone":"(770) 552-2233","street_address":"8610 Roswell Rd","city":"Sandy Springs","state":"GA","zip_code":"30350","website":"www.tonyssportsbar.com/","open_hours":"Mon-Fri 11am-2am, Sat-Sun 12pm-2am","features":"Live entertainment, TVs, billiards, Wi-Fi. ","type":"Sports Bar, Restaurant","coords":"33.989659, -84.351690"}]

Using this code but not getting success

info = jQuery.parseJSON(data);

alert(info.bus_code);

but not getting success.

please suggest me any idea.

1
  • send it by your application as a text (download) to ensure have received in correct format or data. Commented Sep 2, 2013 at 17:03

3 Answers 3

4

Try:

alert(info[0].bus_code);

(The object is within an array).

Sign up to request clarification or add additional context in comments.

Comments

2

Yours data is already in JSON format. so no need to use jQuery.parseJSON(data) and Its an array so use data[0].bus_code

 var data = [{"bus_code":"1103030017","bus_name":"Tony\u0027s Sports Bar \u0026 Grill","first_name":"","last_name":"","email":"[email protected]","phone":"(770) 552-2233","street_address":"8610 Roswell Rd","city":"Sandy Springs","state":"GA","zip_code":"30350","website":"www.tonyssportsbar.com/","open_hours":"Mon-Fri 11am-2am, Sat-Sun 12pm-2am","features":"Live entertainment, TVs, billiards, Wi-Fi. ","type":"Sports Bar, Restaurant","coords":"33.989659, -84.351690"}];
 console.log(data[0].bus_code);

Fiddle

As per @Boaz If you input is string then you have to surely use jQuery.parseJSON

1 Comment

The quoted block in the OP is probably a string.
2

Try this.

alert(info[0]['bus_code']);

or

alert(info[0].bus_code);

See Demo

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.