I have problem with returning string from Lambda after
JSONObject.toString
in return i have
"{\"Key2\":\"Value2\",\"Key1\":\"Value1\"}"
instead of
"{"Key2":"Value2","Key1":"Value1"}"
Can somebody explain how to exclude these slashes?
If you really need to remove them ...
yourstring.replace("\\", "");
However, those "stupid slashes" are necessary if you are treating your response as a string, as they escape your "
character. Specifically, without those, your compiler would behave as such:
"{" // is a string
Key2 // Not known by Java
":" // is a string
Value2 // Not known by Java
"," // is a string
Key1 // Not known by Java
":" // is a string
Value1 // Not known by Java
"}" // is a string
By escaping your "
character with a backslash, you are mentionning to your compiler that it should not be taken as an end of string nor a begin. Thus, asking it to only take in account the first and last "
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With