NutzCN Logo
问答 nutz返回JSONObject怎么去掉最外层"map" ?
发布于 2197天前 作者 qq_e79520c3 2393 次浏览 复制 上一个帖子 下一个帖子
标签:
后台代码
        JSONObject a =new JSONObject("{\"code\":0,\"msg\":\"\",\"count\":66,\"data\":[{\"username\":\"张小三\"," +
                "\"amount\":18,\"province\":\"浙江\",\"city\":\"杭州\",\"zone\":\"西湖区\",\"street\":\"西溪街道\"," +
                "\"address\":\"西溪花园\",\"house\":\"30栋1单元\"},{\"username\":\"李小四\",\"amount\":39,\"province\":\"江苏\"," +
                "\"city\":\"苏州\",\"zone\":\"姑苏区\",\"street\":\"丝绸路\",\"address\":\"天墅之城\",\"house\":\"9幢2单元\"}," +
                "{\"username\":\"王小五\",\"amount\":8,\"province\":\"江西\",\"city\":\"南昌\",\"zone\":\"青山湖区\"," +
                "\"street\":\"艾溪湖办事处\",\"address\":\"中兴和园\",\"house\":\"1幢3单元\"},{\"username\":\"赵小六\",\"amount\":16," +
                "\"province\":\"福建\",\"city\":\"泉州\",\"zone\":\"丰泽区\",\"street\":\"南洋街道\",\"address\":\"南洋村\"," +
                "\"house\":\"6幢1单元\"},{\"username\":\"孙小七\",\"amount\":12,\"province\":\"湖北\",\"city\":\"武汉\"," +
                "\"zone\":\"武昌区\",\"street\":\"武昌大道\",\"address\":\"两湖花园\",\"house\":\"16幢2单元\"}," +
                "{\"username\":\"周小八\",\"amount\":11,\"province\":\"安徽\",\"city\":\"黄山\",\"zone\":\"黄山区\"," +
                "\"street\":\"汤口镇\",\"address\":\"温泉村\",\"house\":\"21号\"}]}");

        return a;
    }
------------------------------------
返回页面数据
{"map":{"msg":"","code":0,"data":[{"map":{"amount":18,"address":"西溪花园","province":"浙江","city":"杭州","zone":"西湖区","street":"西溪街道","house":"30栋1单元","username":"张小三"}}, {"map":{"amount":39,"address":"天墅之城","province":"江苏","city":"苏州","zone":"姑苏区","street":"丝绸路","house":"9幢2单元","username":"李小四"}}, {"map":{"amount":8,"address":"中兴和园","province":"江西","city":"南昌","zone":"青山湖区","street":"艾溪湖办事处","house":"1幢3单元","username":"王小五"}}, {"map":{"amount":16,"address":"南洋村","province":"福建","city":"泉州","zone":"丰泽区","street":"南洋街道","house":"6幢1单元","username":"赵小六"}}, {"map":{"amount":12,"address":"两湖花园","province":"湖北","city":"武汉","zone":"武昌区","street":"武昌大道","house":"16幢2单元","username":"孙小七"}}, {"map":{"amount":11,"address":"温泉村","province":"安徽","city":"黄山","zone":"黄山区","street":"汤口镇","house":"21号","username":"周小八"}}],"count":66}}

怎么去掉返回页面中的map,因为我这个是看一个效果,并不想前端处理map
5 回复

"count":66 也是返回页面后就多出来的

这样拼json也是厉害了

@Ok("json:full")   

因为我只想看修改数据后的前端效果,所以并不想建mode和bean,最后返回对象,我记得之前返回一个对象也是多了外层map,但是那个我前端处理下,所以没在意

如果返回Java对象是没问题的,可能是我JSONObject对象初始化直接放字符串的原因吧。算了,不纠结了,我昨天直接F12一个一个把前端数据改掉看到效果了

添加回复
请先登陆
回到顶部