公告
财富商城
积分规则
提问
发文
2019-01-20 06:50发布
Melony?
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");
We can use the help of Gson
Gson
String result =new Gson().toJson("your data");
NB: jar file needed for Gson
Json2 can help. JSON.stringify(obj)
JSON.stringify(obj)
you need to convert the JSON object to string
JSON object
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.
jsonText
最多设置5个标签!
URL encode your details parameter:
We can use the help of
Gson
NB: jar file needed for Gson
Json2 can help.
JSON.stringify(obj)
you need to convert the
JSON object
to stringNow, you can pass this
jsonText
as parameter.