读书人

小弟我用 uLkJSON 如何用解析json数

发布时间: 2013-07-27 22:21:00 作者: rapoo

我用 uLkJSON ,怎么用解析json数据中的中文。
我用 uLkJSON ,怎么用解析json数据中的中文。
当解析zh_desc的中文值时,显示为控制,而解析code、en_desc是对的。

  
var JSon_Root :TlkJSONobject; var Rlt_Str Rlt_Str :String;
Rlt_Str :='{"error_response":{"code":"22","zh_desc":"授权者不是商家","en_desc":"the franchisor not businessmen"}}'

JSon :=TlkJSON.ParseText(Rlt_Str) as TlkJSONobject;
if JSon.Field['error_response'] <>nil then begin
JSon_Root :=JSon.Field['error_response'] as TlkJSONobject;

with JSon_Root do begin
ShowMessage(getString('code'), ); //22
ShowMessage(getString('en_desc')); //the franchisor not businessmen
ShowMessage(Field['zh_desc'].Value); //为什么是空值,而不是授权者不是商家
end;
end;

[解决办法]
你前面UTF8Dncode,解析的时候还得转回来
Rlt_Str :='{"error_response":{"code":"22","zh_desc":"授权者不是商家","en_desc":"the franchisor not businessmen"}}'
Rlt_Str:=UTF8Encode(Rlt_Str);// 再utf8编码一次
// 再开始解析

读书人网 >.NET

热点推荐