如何在java中将url字符串存储到json对象中


How to store a url string into a json object in java

我正在阅读这个json

{"website": {"url": "http://www.google.com"}}

我将字符串存储在类似的json对象中

//I make a network call to get the string
 JSONObject obj = new JSONObject(website_string);

当我去掉正斜杠时,我没有问题。如何保持前斜线?

以下是实现这一目标的方法:

string urlString = "http:'/'/mywebsite.com";

现在您可以从json中获得结果,并使用进行处理

string url = urlString .replace(''', '');