1.json格式字符串:
? ??String json= "{\"msg\":\"成功\",\"code\":100,\"content\":\"插入3條數(shù)據(jù)\"}";
2.java對象:
? ? ? ? Result result = new Result();
? ? ? ? result.put("msg","成功");
? ? ? ? result.put("code",100);
? ? ? ? result.put("content","插入3條數(shù)據(jù)");
? ? ? ? JsonObject jsonObject = JsonObject.fromObject(result);
????????response.setCharacterEncoding("utf-8");//響應(yīng)字符集的編碼格式? ? ? ?????????response.getWriter().print(jsonObject.toString());? ??
3.Map:
????????Map map=newHashMap();
????????String json= "{\"msg\":\"成功\",\"code\":100,\"content\":"插入3條數(shù)據(jù)"}";
? ? ? ? map.put("json", json);
????????returnjsonMap;????