views:

69

answers:

1

I have the following code:

NSMutableDictionary *jsonObj = [parser objectWithString:json_string error:nil];
NSString *test = [[[jsonObj objectForKey:@"questions"] valueForKey:@"owner"] valueForKey:key];

but what I get back is:

 (
1a19f089a2bc4ee42bff1c102c6e89b8
)

The actual value is fine, but I get those parenthesis, which show up in my string. How can I get rid of them?

+1  A: 

-stringByTrimmingCharactersInSet: with e.g. an inverted alphanumeric character set should work fine here:

cleanStr = [str stringByTrimmingCharactersInSet:
            [[NSCharacterSet alphaNumericCharacterSet] invertedSet]];

But actually that sounds like either the provider of the JSON or the parser should be fixed.

Georg Fritzsche
thanks. I found the bug though. It turns out my NSString should be an NSArray and I what I had to get was objAtIndex:0. I'll accept your answer anyway because I need this code later on in my app
Matt S.