Character encoding via Rest API/JSON

636 views Asked by At

From a RestAPI method call I am getting following JSON output (this is a JSON output from Socialcast RestAPI).

{
   "message":{
      "id":18755210,
      "user":{
         "id":964633,
         "name":"Lasith Chandrasekara",
         "url":"https://searchtechnologies-com.socialcast.com/users/964633-lasithchandrasekara",
      },
      "title":"",
      "body":"\"\u0db8\u0dad\u0dca \u0d9a\u0dd4\u0da9\u0dd4 \u0d9a\u0db1\u0dca\u0da7\u0dda\u0db1\u0dbb\u0dba \u0dc3\u0db8\u0dca\u0db6\u0db1\u0dca\u0db0 \u0dc3\u0dd2\u0daf\u0dca\u0db0\u0dd2\u0dba\u0dda\u0daf\u0dd3 \u0d85\u0d9c\u0db8\u0dd0\u0dad\u0dd2\u0dc0\u0dba\u0dcf\u0d9c\u0dda \u0dbb\u0dd9\u0daf\u0dca\u0daf \u0d9a\u0dd0\u0d9e\u0dd3 \u0db1\u0dd2\u0dbb\u0dd4\u0dc0\u0dad \u0db4\u0dda\u0db1\u0dca\u0db1\u0dda \u0da2\u0dcf\u0dad\u0dd2\u0d9a \u0dc4\u0dd9\u0dc5 \"",
      "action":""
   }
}

I want to process this with java and pass to another system called "save2xml" (which is another java component that take this as a input and save this input as a xml file).

The part of output of savet2xml file as follows.

<body>\"\u0db8\u0dad\u0dca \u0d9a\u0dd4\u0da9\u0dd4 \u0d9a\u0db1\u0dca\u0da7\u0dda\u0db1\u0dbb\u0dba \u0dc3\u0db8\u0dca\u0db6\u0db1\u0dca\u0db0 \u0dc3\u0dd2\u0daf\u0dca\u0db0\u0dd2\u0dba\u0dda\u0daf\u0dd3 \u0d85\u0d9c\u0db8\u0dd0\u0dad\u0dd2\u0dc0\u0dba\u0dcf\u0d9c\u0dda \u0dbb\u0dd9\u0daf\u0dca\u0daf \u0d9a\u0dd0\u0d9e\u0dd3 \u0db1\u0dd2\u0dbb\u0dd4\u0dc0\u0dad \u0db4\u0dda\u0db1\u0dca\u0db1\u0dda \u0da2\u0dcf\u0dad\u0dd2\u0d9a \u0dc4\u0dd9\u0dc5 \"</body>

How can I get decoded string (like follows) with the output of save2xml? "මත් කුඩු කන්ටේනරය සම්බන්ධ සිද්ධියේදී අගමැතිවයාගේ රෙද්ද කැඞී නිරුවත පේන්නේ ජාතික හෙළ "

Note: I debugged the save2xml component as follows and it print encoding as cp1252.

OutputStreamWriter out = new OutputStreamWriter(new ByteArrayOutputStream());
    getLogger().info("XXXXXXX ecndoing is " + out.getEncoding());

So here I don't want to change save2xml component. What I can do is process JSON and do whatever modification before passing to the save2xml component. Please advice the change I have to done when processing the JSON to get decoded (readable) output in xml.

I guess the JSON is in UTF-8.

0

There are 0 answers