Pergunta

Already i have worked on SBJSON parsing, that was working very fine. Now, i am working in SBJSON parsing. The problem is the parsing result is returning null(In NSDictionary). I have tested the url in Firefox POST tool, it returned result with the Content-Type = application/x-www-form-urlencoded and Method = POST. How to use Content-Type and Method[POST, GET] in SBJSON file parsing? Really i can not find the result in google search(sorry). Please help me to solve my problem. Please suggest me any sample code or idea. Thanks in advance.

This is my code,

SBJSON *jsonParser = [[SBJSON new] autorelease];
    NSURL *urls = [NSURL URLWithString:[NSString stringWithFormat:@"SAMPLE URL"]];
    NSString *stringUrl = [NSString stringWithFormat:@"%@",urls];
    NSDictionary *dictionary = (NSDictionary *) [jsonParser objectWithString:stringUrl error:nil];
    NSLog(@"Dictionary : %@", dictionary);

The dictionary is returning null. How to use Content-Type and [POST,GET] methods in SBJSON file parsing?

Thanks in advance.

Foi útil?

Solução

You are not actually fetching the string data at the URL, just creating a URL and parsing that, which unsurprisingly, cannot be converted to a JSON object. You should asynchronously fetch the string data using something like NSURLConnection, or easier ASIHTTP, then parse the result.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top