Json response should look like :
"{\"syncrequest\":{\"user\":{\"@xmlns:xsi\":\"http://www.w3.org/2001/XMLSchema-instance\",\"active\":\"true\",\"basedataset\":\"false\"},\"syncversion\":\"89\",\"syncdata\":[{\"operation\":\"INSERT OR REPLACE\",\"table\":\"WSInformation\",\"rows\":[{\"WS_ID\":\"71\",\"WS_ParentOwn\":null,\"WS_Notes\":\"Notes\\"for\\"VistaStore Fleet\\"save\",\"CC_ID\":\"1\",\"Record_Instance\":\"1\",\"Record_LastModified\":\"2013-11-26T07:51:35.203\"}]}]}}"
Response coming from server with a string format. When i convert the above string in json format using
JsonObject jObject =new JsonObject(string);
its getting error like unterminated character in string.
Can any body help me out for above problem.
Thanks In advance
Edited :
The response coming from server is in the form of input stream .
So, I used to convert the inputstream to string using the function :
IOUtils.readStream(instream);
Then the response string should like :
string response =
"{\"syncrequest\":{\"user\":{\"@xmlns:xsi\":\"http://www.w3.org/2001/XMLSchema-instance\",\"active\":\"true\",\"basedataset\":\"false\"},\"syncversion\":\"89\",\"syncdata\":[{\"operation\":\"INSERT OR REPLACE\",\"table\":\"WSInformation\",\"rows\":[{\"WS_ID\":\"71\",\"WS_ParentOwn\":null,\"WS_Notes\":\"Notes\\"for\\"VistaStore Fleet\\"save\",\"CC_ID\":\"1\",\"Record_Instance\":\"1\",\"Record_LastModified\":\"2013-11-26T07:51:35.203\"}]}]}}"
By using the below function to form the json object,I removing the double quotes.
res = response.substring(1, response.length() - 1);
and removing double quotes with in the string using the below function.
res = response.replace("\\"", "\"");