1

I'm just recogniced that this code:

try {
        String jsonString =new JSONObject().put("test","Ha/llo").toString();
    } catch (JSONException e) {
        e.printStackTrace();
    }

ouputs the following:

{"test":"Ha\ /llo"}

Does someone knows why it puts an \ for each / ? And how to get the real String? My Strings i want to put are supposed to be big, so I dont want to search for \ to change it to ' '

Edit: .get decodes it again and removes the extra '\' in my case is was an server side problem.

1

1 Answer 1

1

It is escaping the / character automatically. When a valid JSON client parses your string, it should unescape it, resulting in no issues and the original text. See JSON: why are forward slashes escaped?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.