LKM
LKM

Reputation: 2450

JSON string is weird

I send JSON at node : response.json(object);

and I get json at android :

 String json_string = EntityUtils.toString(response.getEntity());

And json_string from android :

"{\"query\":{\"count\":4,\"created\":\"2014-11-07T15:10:16Z\",\"lang\":\"en-US\",\"diagnostics\":{\"publiclyCallable\":\"true\", ~ }

It's different from what I generally got.

character '"' and '\' is added to json string So I'm troubling in getting the result from json string.

Is there something wrong?

Upvotes: 0

Views: 200

Answers (2)

user468311
user468311

Reputation:

Your string is just escaped, to keep special characters like double quotes. If there was no escaping, then your string would look just like that:

"{\"

So you need to indicate that some of double quotes shouldn't be treaded like end of the string. Refer to http://docs.oracle.com/javase/tutorial/java/data/characters.html

Upvotes: 2

Lokesh
Lokesh

Reputation: 3334

Its okk, You are getting just raw json. Do one thing cast this string in StringBuilder and again StringBuilder to string. Its remove all "\ character. Try this its works for me

Upvotes: 2

Related Questions