2012-03-29 5 views
0

私は次のJSONデータ持っYAJLiOSパーサ... について質問があります:YAJLiOSは英語以外の文字を解析できません。

{{ 
    body = "Привет"; 
    mid = 3; 
    "read_state" = 1; 
    } 
    { body = "hi"; 
    mid = 3; 
    "read_state" = 1; 
    }} 

と私は "身体" を取得しようとしているが、結果は次のとおりです。 "\ U0416用の\ U0412" と "こんにちは"

はそれがエンコーディングに問題があるかもしれませんが、私はあなたの時間のためにそれ

感謝を修正する方法は考えていません!

+0

解析を行っている場所のコードを表示できますか? – jonkroll

+0

sure: NSString * getFriendDialogs = [NSString stringWithFormat:@ "https://api.vk.com/method/messages.getHistory?access_token=%@&uid=%@&chat_id=uid&count=10"、currentAccessToken、UidOfSelectedFriend】 ; NSURL * url = [NSURL URLWithString:getFriendDialogs]; NSURLRequest * requestObj = [NSURLRequest requestWithURL:url]; NSData * tempContainer = [NSURLConnection sendSynchronousRequest:requestObj returningResponse:nil エラー:nil]; NSDictionary * dialogsDictionary = [tempContainer yajl_JSON]; idString = [dialogsDictionary valueForKey:@ "body"]; – ignotusverum

答えて

0

UTF-8文字エンコーディングを処理するには、まず文字列に変換する必要があります。

NSData *tempContainer = [NSURLConnection sendSynchronousRequest:requestObj returningResponse:nil error:nil]; 

NSString *tempString = [NSString stringWithUTF8String:[tempContainer bytes]]; 

NSDictionary *dialogsDictionary = [tempString yajl_JSON]; 
+0

ありがとうございますが、これは役に立ちません; – ignotusverum

+0

他の文字エンコーディングがありますか? – ignotusverum

+0

NSData tempContainer = [NSURLConnection sendSynchronousRequest:requestObj returningResponse:nil error:nil]; NSString content = [[NSString alloc] initWithData:tempContainer encoding: NSUTF8StringEncoding];このコードを使用するとすべてOKですが、nsdictionaryではなくnsstringが必要です – ignotusverum

関連する問題