PDA

View Full Version : سوال: نمایش کاراکترهای فارسی در خواندن از json



baran_2005
سه شنبه 03 بهمن 1396, 18:30 عصر
برای نمایش فارسی مشکل دارم به صورت علامت سوال نمایش میده . لطفا راهنمایی . سپاس



procedure TForm1.Button2Click(Sender: TObject);
var
JSonObject:TJSonObject;
JSonValue:TJSonValue;
st:string;
Begin
st :=UTF8Encode( '{"data":{"records":[{"stname":"نمايشگاه","StId":1},{"stname":"پارک","StId":2},{"stname":"تقي آباد","StId":3},{"stname":"پیروزی","StId":4},{"stname":"استقلال","StId":5}],"status":true}}');
JSonObject := TJSonObject.Create;
JsonValue:=JSonObject.ParseJSONValue( st);
memo1.text:=( (JsonValue as TJSONObject).Get('data').JsonString.Value);
JSonObject.Free;
end;

baran_2005
چهارشنبه 04 بهمن 1396, 09:24 صبح
با کد زیر مشکل حل شد !



const
Text ='{"data":{"records":[{"stname":"نمايشگاه","StId":1},{"stname":"فلکه پارک","StId":2},{"stname":"تقي آباد","StId":3},{"stname":"طلاب","StId":4},{"stname":"نخريسي","StId":5}],"status":true}}';
var
JSONObject, JSONObject2, currcond: TJSONObject;
arrayjson: TJSONArray;
i:integer;
begin
JSONObject := TJSONObject.ParseJSONValue(Text) as TJSONObject;
JSONObject2 := JSONObject.GetValue('data') as TJSONObject;
arrayjson := JSONObject2.GetValue('records') as TJSONArray;
for i :=0 to arrayjson.Count-1 do
begin
currcond := arrayjson.Items[i] as TJSONObject;
showmessage(currcond.GetValue('stname').Value);
end;