In the category list in the documentation, there are overall categories (Food, Restaurants, Health), and many sub categories within them. However, when I make a request and parse the JSON, the only categories that are returned are the sub-categories.
Even the example json in the documentation doesn't have the overall categories
"categories": [
[
"Local Flavor",
"localflavor"
],
[
"Mass Media",
"massmedia"
]
],
If I search for restaurants, the categories will return things like "italian, french, american", but not "restaurants". Is there a way to get the overall category in the json so I can use it?
Thanks
Use the search API instead, and set a category_filter according to this list.
This should give you all the "objects" in the given category.
Something like this http://api.yelp.com/v2/search?category_filter=restaurants.
Update
It seems like I misunderstood a little... so you want to get the root category.
(eg. for "italian"–>"restaurants", "french"->restaurants, "car dealers"->automotive etc.)
I think you have two options:
Hardcode the dictionary of all restaurant subcategories (french,italian...) into a file (plist, json, whatever) and after getting the "object" you could check if the subcategory is included in the hard-coded subcategories dictionary.
Use the search API and provide the bussiness id and category_filter set to restaurants and check if it returns any result - if not, then the object is not in the right category.
The reason why I am suggesting to hard code it is, because Yelp doesn't provide an API to get complete list of categories.
In my opinion I would try the approach #1, because it is less intensive on the network side and a dictionary is blazing fast.
But to answer your initial question, no it is not possible to have the root category in the JSON file.
I have a json string but the format is strange
[[5706,[
[1132001,"Aston Villa","West Ham",5706,'2010-08-14T15:00:00.0000000',[[1966752,0],[1977724,1]],[],"","","","",64,63],
[1132002,"Blackburn","Everton",5706,'2010-08-14T15:00:00.0000000',[[1966753,0],[1977721,1]],[],"","","","",83,66],
[1132004,"Bolton","Fulham",5706,'2010-08-14T15:00:00.0000000',[[1966755,0],[1977727,1]],[],"","","","",88,85],
[1132005,"Chelsea","West Brom",5706,'2010-08-14T15:00:00.0000000',[[1966756,0],[1977712,1]],[],"","","","",503,94],
[1132006,"Liverpool","Arsenal",5706,'2010-08-14T15:00:00.0000000',[[1966757,0],[1977733,1]],[],"","","","",59,58],
[1132007,"Man Utd","Newcastle",5706,'2010-08-14T15:00:00.0000000',[[1966758,0],[1977730,1]],[],"","","","",19,70],
[1132008,"Sunderland","Birmingham",5706,'2010-08-14T15:00:00.0000000',[[1966759,0],[1977715,1]],[],"","","","",60,86],
[1132009,"Tottenham","Man City",5706,'2010-08-14T15:00:00.0000000',[[1966760,0],[1977739,1]],[],"","","","",62,77],
[1132010,"Wolves","Stoke City",5706,'2010-08-14T15:00:00.0000000',[[1966761,0],[1977718,1]],[],"","","","",81,342],
[1146485,"Wigan","Blackpool",5706,'2010-08-14T15:00:00.0000000',[[1998244,0],[1998321,1]],[],"","","","",350,328]],
[[1015824,8],[1035605,126]]]]
So, How can i parse and extract it value?
Thanks
Just eval it using whatever library is relevant to the language you're parsing it into. The format is a list of values and lists - so from the resulting structure you'll just need to traverse the lists to get to the pieces that you're interested in. Without more context, I can't provide any brilliant insight into what the values mean in those lists, but doing a little googlin' digging makes me thing you're looking at data related to football club tickets and/or games.