I want to send json data in url as below .
editTest.jsp?details=374889331-{"aNumber":2}
How can I do this?
URL encode your details parameter:
String otherParameter = "374889331-";
String jsonString = "{\"aNumber\":2}";
String url = "editTest.jsp?details=" + URLEncoder.encode(otherParameter + jsonString, "UTF-8");
you need to convert the JSON object to string
JSONObject obj = new JSONObject();
obj.put("name","foo");
StringWriter out = new StringWriter();
obj.writeJSONString(out);
String jsonText = out.toString();//JSON object is converted to string
Now, you can pass this jsonText as parameter.
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