java - GSON JsonObject getAsString() UTF-8 issue -
i have json value "test":"d'exécuter" , when print gson's getasstring()
method displays d\u0027ex├âŒ?cuter or d'ex??cuter. how actual value "d'exécuter"?
string envservices = system.getenv("services"); jsonobject services = new jsonparser().parse(envservices).getasjsonobject(); jsonarray arr = (jsonarray) services.get("dev.dev"); //$non-nls-1$ if (arr.size() > 0) { services = arr.get(0).getasjsonobject(); jsonobject credentials = services.get("credentials").getasjsonobject(); string val = new string((credentials.get("test").getasstring()).getbytes("utf-8")); string val1 = new string((credentials.get("test").getasstring())); }
the json value follows
services={"dev.dev": [{ "name": "wds", "credentials": { "url": "http://test.com", "username": null,"test":"d'exécuter", "password": null } } ] }
Comments
Post a Comment