Posts mit dem Label valid JSON produces JSON error werden angezeigt. Alle Posts anzeigen
Posts mit dem Label valid JSON produces JSON error werden angezeigt. Alle Posts anzeigen

Mittwoch, 28. Oktober 2015

JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING

At first glance you would expect an error like this:


JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING


quite simple: the JSON is incorrect.

But what if JSONLint even validates this as correct?


In this example, the code was produced by an Android App consuming a JSON interfaces produced by PHP.


And guess what?!


It was an UTF-8 encoding issue within the JSON content - a special character from a town name needed UTF-8 encoding.


This solves the issue and saved my Friday!