Delphi JSON Encode with Tsslhttpcli (Overbyte ICS)

Asked

Viewed 343 times

0

I am using the Tsslhttpcli component of Overbyte www.overbyte.I and I’m having problems with formatting my return json, with special characters, I’m consuming the google’s Geolocation api, see return:

{
   "results":[
      {
         "address_components":[
            {
               "long_name":"São Paulo",
               "short_name":"São Paulo",
               "types":[
                  "locality",
                  "political"
               ]
            },
            {
               "long_name":"São Paulo",
               "short_name":"São Paulo",
               "types":[
                  "administrative_area_level_2",
                  "political"
               ]
            },
            {
               "long_name":"State of São Paulo",
               "short_name":"SP",
               "types":[
                  "administrative_area_level_1",
                  "political"
               ]
            },
            {
               "long_name":"Brazil",
               "short_name":"BR",
               "types":[
                  "country",
                  "political"
               ]
            }
         ],
         "formatted_address":"São Paulo, State of São Paulo, Brazil",
         "geometry":{
            "bounds":{
               "northeast":{
                  "lat":-23.3566039,
                  "lng":-46.3650844
               },
               "southwest":{
                  "lat":-24.0082209,
                  "lng":-46.825514
               }
            },
            "location":{
               "lat":-23.5505199,
               "lng":-46.63330939999999
            },
            "location_type":"APPROXIMATE",
            "viewport":{
               "northeast":{
                  "lat":-23.3566039,
                  "lng":-46.3650844
               },
               "southwest":{
                  "lat":-24.0082209,
                  "lng":-46.825514
               }
            }
         },
         "place_id":"ChIJ0WGkg4FEzpQRrlsz_whLqZs",
         "types":[
            "locality",
            "political"
         ]
      }
   ],
   "status":"OK"
}

for example the word "Saint Paul", I have already changed the encoding, I’ve already changed some settings like "Accept", "Acceptlanguage", "Agent", "Contenttype", "Contentencoding" and nad, does anyone know how to fix it? below my Httpcli code..

HttpCli.Connection      := 'Keep-Alive';
HttpCli.RequestVer      := '1.0';
HttpCli.RcvdStream      := TMemoryStream.Create;;
HttpCli.URL := 'url api...';
HttpCli.Get;

if HttpCli.StatusCode <> 200 then
  begin
   HttpCli.RcvdStream.Free;
   HttpCli.RcvdStream := nil;
   Result := '';
   Exit;
  end;

HttpCli.RcvdStream.Seek(0, 0);
SetLength(Data, HttpCli.RcvdStream.Size);
HttpCli.RcvdStream.Read(Data[1], Length(Data));
xHtmlTemp := String(Data);

1 answer

0


not configuration and component properties, just change

xHtmlTemp := String(Data);

for

xHtmlTemp := UTF8Decode(Data);

I wondered why in the other component I used I didn’t need this conversion.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.