0

resultString is "{lhs: "100 Indian rupees",rhs: "1.8612 U.S. dollars",error: "",icc: true}"

i have a string , in this four fields available . now how i can fetch second field of this string. Coz i want to use value = 1.8612 U.S. dollars. my problem is that my value is in double quotes but the key isn't. please help me in this parsing.

2 Answers2

0

this seems json. study some json tutorials

EDIT:

here is a link to tutorial

http://www.touch-code-magazine.com/tutorial-fetch-and-parse-json/

Saad
  • 8,857
  • 2
  • 41
  • 51
0

The String you wrote above is a JSON String. You need to parse it and you will get a NSDictionary. You can get the fastest JSON Parser here:

Nextive JSON Parser

Anyways the JSON String, that you have given has some errors into it. The proper string is:

{
"lhs":"100 Indian rupees",
"rhs": "1.8612 U.S. dollars",
"error": "",
"icc": true
}

And When it'll be parsed it looks like: You'll get 4 keys {lhs,rhs,error,icc} & respective values in NSDictionary.

Hope it works for you.

Edit: If you want to check for a valid JSON String: You can check is

JSON Parser.

This link will let you know where is the error in your JSON String(if error). Else will show you parsed JSON.

iCreative
  • 1,499
  • 1
  • 9
  • 22
  • your suggestion is right but i am getting the string from the url like {lhs: "100 Indian rupees",rhs: "1.8612 U.S. dollars",error: "",icc: true}. now i want to get value of rhs. – yatindra jain Oct 25 '12 at 07:19
  • Please try parsing the string you receive using JSON Parser, that i have mentioned above. I hope it'll be OK. – iCreative Oct 25 '12 at 09:38