I use ASIHTTPRequest to get a token, and I receive this string:
{Token:[{"new":"jkajshdkjashdjhasjkdhjkhd+sd==sfbjhdskfbks+sdjfbs=="}]}
I used JSON Framework from here: http://stig.github.com/json-framework.
This is the code after I get the string:
- (void)requestFinished:(ASIHTTPRequest *)req
{
    NSString *responseString = [req responseString];
    NSLog(@"Response: %@", [req responseString]);
    // Parse the response
    SBJsonParser *jsParser = [SBJsonParser new];
    id content = [responseString JSONValue];
    if(!content){
        // Parsing error
        NSLog(@"%@", jsParser.errorTrace);
    }
}
NSLog(@"ID: %@", content);
I receive this error:
 -JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Object key string expected\" UserInfo=0x5a418a0 {NSLocalizedDescription=O开发者_开发百科bject key string expected}"
)
My guess is that, the JSON Framework that I am using cant understand the response string format:
{Token:[{"new":"jkajshdkjashdjhasjkdhjkhd+sd==sfbjhdskfbks+sdjfbs=="}]}
Is there any other way to parse the value?
Happy programming, Johnie
It was looking for a start and end " surrounding Token.
{"Token":[{"new":"jkajshdkjashdjhasjkdhjkhd+sd==sfbjhdskfbks+sdjfbs=="}]}
There's a bug in this code:
SBJsonParser *jsParser = [SBJsonParser new];
id content = [responseString JSONValue];
if(!content){
    // Parsing error
    NSLog(@"%@", jsParser.errorTrace);
}
You instantiate a parser, jsParser, but don't use it to parse the string. (The JSONValue method instantiates a new parser internally.) Then you read the error from the parser that was not used to parse the string.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论