-4

I am getting a JSON like this:

{
    response =  {
        message = (
            "Permission denied, you do not have permission to access the requested page."
        );
    };
}

I want to print:

"Permission denied, you do not have permission to access the requested page."

How can I get the value?

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Nikita Patil
  • 674
  • 1
  • 7
  • 17
  • Read the braces / parentheses `{}` is dictionary, key subscripted `()` is array, index subscripted. The string is the first item in the array for key `message` in the dictionary for key `response` in the root dictionary. – vadian Nov 29 '17 at 15:07
  • try parsing the JSON as a first step – and you will figure out the rest. – holex Nov 29 '17 at 15:08
  • This will help you - https://stackoverflow.com/questions/5547311/how-do-i-parse-json-with-objective-c – Krunal Nov 29 '17 at 15:08

1 Answers1

0

In Objective C

 NSArray *arrRes = [[jsonRes objectForKey:@"response"] objectForkey:@"message"];
 NSLog(@"The output result is - %@",arrRes);

Then if you want to print the string from the array do like below

for(int i=0;i<arrRes.count;i++){
        NSString *strRes = arrRes[i];
        NSLog(@"The strRes is - %@",strRes);
}
user3182143
  • 9,459
  • 3
  • 32
  • 39