java - JSONArray问题。。。.

 若_时光倒影 发布于 2022-10-30 10:12
public Map delete(JSONObject head, JSONObject body)
            throws Exception {
        Map attributes=new HashMap();
        JSONArray couponJson=body.optJSONArray("couponId");
         
            String token=head.optString("token");
        Object object=UserCacheManage.getAppUser(token);
        
        //if(object!=null){
        //UserCache user=(UserCache)object;
        String userId="4028668150c6aedb0150c6ddde750005";
        HhUserEntity hhUserEntity=super.getEntity(HhUserEntity.class, userId);
        if(hhUserEntity!=null){
            String ids="";
            Object [] couponIds=(Object[])couponJson.toArray();
            if(couponIds!=null&&couponIds.length>0){
                for(int i=0;i list = super.findByQueryString(hql);
            if(list!=null&&list.size()>0){
                super.deleteAllEntitie(list);
            }

我要取到couponId然后批量删除实体,但是body.optJSONArray("couponId")得到的是object类型不是jsonarry类型,这怎么办- -

1 个回答
  • 直接强转不行?

    2022-10-31 21:20 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有