Bunny83 / SimpleJSON

A simple JSON parser in C#
MIT License
735 stars 294 forks source link

Problem with parsing a JSON file on Android #10

Closed Ryumizuhi closed 6 years ago

Ryumizuhi commented 6 years ago

Hi I have a problem when I try to parse a file with JSON an Android device.

The line 58 of the file below return a warning "Unsupported encoding: 'iso-8859-1,application/json'". And the line 65 return a null value.

creationdropdownassetbundle

The JSON file that I download with the WWW function : api_bmu2

What can I change to make it work ?

Marie

Bunny83 commented 6 years ago

This doesn't seem to be related to parsing the text as it looks like your text doesn't arrive with a known encoding. The response from the server seems to be "iso-8859-1" encoded which is latin-1

The best solution would be if you could make your server to return an utf8 encoded string. So you could try including an "Accept-Charset" request header and requesting utf8 encoding.

If that doesn't work you would need to use the iso-8859-1 encoding to properly translate the received bytes into a string. Something like that:

System.Text.Encoding iso_8859_1 = System.Text.Encoding.GetEncoding("iso-8859-1");
string text = iso_8859_1.GetString(www2.bytes);

Though working with utf8 would be the prefered solution.

Ryumizuhi commented 6 years ago

Thank, I have just add https:// before the adresse and the request work.