【发布时间】:2016-04-29 07:37:20
【问题描述】:
我正在使用以下代码,尝试将 JSON 行发送到客户端,用于测试目的:
String json = "{'nombre':'Donell', 'dni':'351351P'}";
response.setContentType("application/json");
PrintWriter out = response.getWriter();
JSONObject jsonObj = (JSONObject) JSONValue.parse(json);
out.print(jsonObj);
我正在使用库 json-simple,但这不起作用。当我访问我的测试 servlet“/Prueba”时,我收到一个包含 200 个代码类型“json”的包,但没有数据:
这里有什么问题?谢谢!
编辑:尝试只编写 json 时,我看到了,但出现错误:
【问题讨论】: