我需要从json字段中提取网址。(用“”代替,不要破坏json格式),这样json中就没有url了。
网址看起来像这样
"source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\",
"profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/3475536942\/2b0ccd9e42754adf7e22947037dd8c34_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/488849893\/1364691799",
...
我注意到url中有“\”来转义字符串,我不知道在编写正则表达式时如何处理它。
只需使用轻量级 JSON 解析器,例如Java 中的此参考实现
要将source
属性覆盖为“等等”,可以做一些简单的事情
String newJsonString = new JSONObject(originalJsonString).putString("source","blah").toString();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句