java - URL in JSON object as POST request Android -
please me send json object in post http request through httpclient, in android.
the problem facing json object having url replaced forward slash ,i.e
originally should have following value in json object
{"product": {"featured_src":"https:\/\/example.com\/wp-content\/uploads\/2015\/06\/sidney-compressed.jpg, "short_description":"this test","title":"raiders north"} }
i tried many options keep in above format. comes {"featured_src":
we assume input
private final static string json_data = "{" + " \"product\": [" + " {" + " \"featured_src\": \"https:\\/\\/example.com\\/wp-content" + "\\/uploads\\/2015\\/06\\/sidney-compressed.jpg\"," + " \"short_description\": \"this test\"," + " \"title\" : \"raiders north\"" + " }" + " ]" + "}";
you use replace
trick.
your_string.replace("\\", "");
finally method this, passing string parameter
private static string jsonurlcorrector(string json_data) { json_data = json_data.replace("\\", ""); return json_data; }
here input:
{"product":[{"featured_src":"https:\/\/example.com\/wp-content\/uploads\/2015\/06\/sidney-compressed.jpg","short_description": "this test","title":"raiders north"}]}
here output
{"product":[{"featured_src":"https://example.com/wp-content/uploads/2015/06/sidney-compressed.jpg","short_description":"this test","title":"raiders north"}]}
Comments
Post a Comment