0

I am working on one Webservice app .

They give me response like :

JSON RESPONSE:

{"1":"03:30 PM To 04:30 PM","2":"01:30 PM To 02:30 PM","3":"02:30 AM To 03:30 PM","4":"04:30 PM To 05:30 PM","5":"05:30 PM To 06:30 PM","6":"06:30 PM To 07:30 PM"}

And I want to Show all this TIME intervel with Check box in my another View controller so User can select it .

How do I get this ...

Need help

2
  • To get an array it would need to have [] brackets around the array. componentsSeparatedByString as described below should work. Commented Sep 1, 2012 at 9:10
  • check my answer and if you got any problem then ask me.... Commented Sep 1, 2012 at 9:40

3 Answers 3

2

Check out the documentation for NSArray componentsSeparatedByString:(NSString *). This will separate the Json reply into an array at the string you specify. I would probably use @",".

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

Comments

1

You can use SBJson classes to parse json data,

here is the like to get all classes

SBJson

Comments

0

You can simply parse the JSON by following Method

NSString* strJSONResponse = @"{\"1\":\"03:30 PM To 04:30 PM\",\"2\":\"01:30 PM To 02:30 PM\",\"3\":\"02:30 AM To 03:30 PM\",\"4\":\"04:30 PM To 05:30 PM\",\"5\":\"05:30 PM To 06:30 PM\",\"6\":\"06:30 PM To 07:30 PM\"}";

NSDictionary* dataDict = [strJSONResponse JSONValue];

NSLog(@"%@",dataDict);

Here is the output:

Printing description of dataDict:
{
    1 = "03:30 PM To 04:30 PM";
    2 = "01:30 PM To 02:30 PM";
    3 = "02:30 AM To 03:30 PM";
    4 = "04:30 PM To 05:30 PM";
    5 = "05:30 PM To 06:30 PM";
    6 = "06:30 PM To 07:30 PM";
}

With this dictionary you can simply make use as per your requirement.

Here you will need to include Required classes for SBJSON found here

I had to add "\" as an escape characters to use it as a string.

Hope it helps

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.