I am trying to parse the JSON file shown below, and get the coordinates of the place with specific name:
{"Theaters":[{"TheaterName":"Name1","GPSLocation":"3.888689,35.519845"},{"TheaterName":"Name2","GPSLocation":"33.867444,3.527002"},{"TheaterName":"Name3","GPSLocation":"33.897403,3.563645"},{"TheaterName":"Name4","GPSLocation":"34.438693, 3.831660"},{"TheaterName":"Name5","GPSLocation":"3.88392,35.48333"},{"TheaterName":"Name6","GPSLocation":"33.88424,35.483145"},{"TheaterName":"Name7","GPSLocation":"33.972802, 3.610099"},{"TheaterName":"Name8","GPSLocation":"33.857193,35.526886"},
{"TheaterName":"Name9","GPSLocation":"3.36394,35.735929"},{"TheaterName":"Name10","GPSLocation":"3.897403,35.563645"},{"TheaterName":"Name11","GPSLocation":"33.886605,3.508580"},{"TheaterName":"Name12","GPSLocation":"33.892134,3.517423"},
{"TheaterName":"Name13","GPSLocation":"3.917253,35.589074"},{"TheaterName":"Name14","GPSLocation":"33.2860,35.6115"}]}
The query i’m using is shown below, however the response is that expression couldn’t be evaluated. What is the problem?? Thanks
var coordinates = from p in JSON["Theaters"].Children()
where p["TheaterName"].Value<string>() == Name1
select p["GPSLocation"].Values();
Wouldn’t you want the following?
After all, your GPSLocation is a comma separated list.