javascript code: (It creates a json object -> convert to json string -> upload to firebase)
var data = {}
data.systemId = "21341"
// convert json to string
var dataString = JSON.stringify(data);
// push to firebase
var update = {}
update[1718964] = dataString
firebase.database().ref("/data").update(update)
Now the data in firebase console looks like:
Now i try to read the data in Java using Apache httpClient
HttpGet httpGet = new HttpGet(url);
response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
String dataString = EntityUtils.toString(entity);
System.out.println(dataString);
// ABOVE sysout exactly prints below with quotes included
// "{\"systemId\":\"21341\"}"
I was expecting it to print.
{"systemId" : "21341"}
So why it is printing data with \
and starting ending quotes?
WHy i expect it to print it without quotes and slash is based on below code
String temp = "{\"systemId\" : \"21341\"}"
System.out.println(temp);
// prints
//{"systemId" : "21341"}
What mistake am i making ? PS: The content type of the get request is "application/json" but content received is just a string... the problem i think is in how i am handling the data in java.. but still dont know how to fix it?