0

Possible Duplicate:
Parsing JSON using Json.net

I want to pull two values from this test string and save then as their own strings, the values I want our the first and second values in the following piece of text, the values for distance and duration, they are 178331, and 7761. The string I want to pull them from is as follows.

{
   "destination_addresses" : [ "1508-1520 38th Ave, Oakland, CA 94601, USA" ],
   "origin_addresses" : [ "800-828 Mountain Ranch Rd, San Andreas, CA 95249, USA" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "111 mi",
                  "value" : 178331
               },
               "duration" : {
                  "text" : "2 hours 9 mins",
                  "value" : 7761
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}
Community
  • 1
  • 1
Eric
  • 1

1 Answers1

3

What you have here is definitely JSON and should be treated as such. To get the data you need to parse this. Try parsing using either the built in JavaScriptSerializer class or JSON.NET. (for more information, as pointed out by Shadow Wizard: Parsing JSON using Json.net)

Community
  • 1
  • 1
Michael
  • 2,910
  • 3
  • 15
  • 26