当前位置: 首页>>代码示例>>Java>>正文


Java JSONArray.getJSONObject方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.JSONArray.getJSONObject方法的典型用法代码示例。如果您正苦于以下问题:Java JSONArray.getJSONObject方法的具体用法?Java JSONArray.getJSONObject怎么用?Java JSONArray.getJSONObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.JSONArray的用法示例。


在下文中一共展示了JSONArray.getJSONObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rolePermission

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Override
public int rolePermission(JSONArray datas, int id) {
    List<Integer> deleteIds = new ArrayList<>();
    for (int i = 0; i < datas.size(); i ++) {
        JSONObject json = datas.getJSONObject(i);
        if (!json.getBoolean("checked")) {
            deleteIds.add(json.getIntValue("id"));
        } else {
            // 新增权限
            UpmsRolePermission upmsRolePermission = new UpmsRolePermission();
            upmsRolePermission.setRoleId(id);
            upmsRolePermission.setPermissionId(json.getIntValue("id"));
            upmsRolePermissionMapper.insertSelective(upmsRolePermission);
        }
    }
    // 删除权限
    if (deleteIds.size() > 0) {
        UpmsRolePermissionExample upmsRolePermissionExample = new UpmsRolePermissionExample();
        upmsRolePermissionExample.createCriteria()
                .andPermissionIdIn(deleteIds)
                .andRoleIdEqualTo(id);
        upmsRolePermissionMapper.deleteByExample(upmsRolePermissionExample);
    }
    return datas.size();
}
 
开发者ID:sunzhen086,项目名称:lambo,代码行数:26,代码来源:UpmsRolePermissionServiceImpl.java

示例2: getProcessOrders

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
private List<ProcessOrder> getProcessOrders(ProcessPo processPo) {
    JSONArray jsonArray = JSON.parseArray(processPo.getProcessOrder());
    List<ProcessOrder> processOrders = new ArrayList<>();
    for (int i = 0; i < jsonArray.size(); i++) {
        ProcessOrder processOrder = new ProcessOrder();
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        processOrder.setProcessOrder(jsonObject.getInteger("processOrder"));
        try {
            processOrder.setProcessClass(Class.forName(jsonObject.getString("processClazz")));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        processOrders.add(processOrder);
    }
    return processOrders;
}
 
开发者ID:Yanweichen,项目名称:SimpleProcessControl,代码行数:17,代码来源:ProcessCRUDService.java

示例3: permission

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Override
public int permission(JSONArray datas, int id) {
    for (int i = 0; i < datas.size(); i ++) {
        JSONObject json = datas.getJSONObject(i);
        if (json.getBoolean("checked")) {
            // 新增权限
            UpmsUserPermission upmsUserPermission = new UpmsUserPermission();
            upmsUserPermission.setUserId(id);
            upmsUserPermission.setPermissionId(json.getIntValue("id"));
            upmsUserPermission.setType(json.getByte("type"));
            upmsUserPermissionMapper.insertSelective(upmsUserPermission);
        } else {
            // 删除权限
            UpmsUserPermissionExample upmsUserPermissionExample = new UpmsUserPermissionExample();
            upmsUserPermissionExample.createCriteria()
                    .andPermissionIdEqualTo(json.getIntValue("id"))
                    .andTypeEqualTo(json.getByte("type"));
            upmsUserPermissionMapper.deleteByExample(upmsUserPermissionExample);
        }
    }
    return datas.size();
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:23,代码来源:UpmsUserPermissionServiceImpl.java

示例4: getTags

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
public static List<Tag> getTags (boolean useCache) throws APIException {
    if (DEBUG) Log.i(TAG, "-> getTags");
    try {
        String text = NetworkUtil.get(ApiManager.API_TAGS, useCache);
        if (DEBUG) Log.i(TAG, "-> get -> success");
        JSONObject root = JSON.parseObject(text);
        JSONArray data = root.getJSONArray("data");
        List<Tag> tags = new ArrayList<>();
        for (int i = 0; i < data.size(); i ++) {
            JSONObject object = data.getJSONObject(i);
            Tag tag = getTag(object.getInteger("id"), object);
            if (DEBUG) Log.i(TAG, "Adding " + tag.toString());
            tags.add(tag);
        }
        return tags;
    } catch (IOException|JSONException e) {
        throw new APIException(e);
    }
}
 
开发者ID:ProjectFishpond,项目名称:TPondof,代码行数:20,代码来源:TagManager.java

示例5: pinch

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
private static boolean pinch(JSONArray actions) throws Exception {
    for (int i = 0; i < actions.size(); i++) {
        JSONObject action = actions.getJSONObject(i);
        if(!pinch(action)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:10,代码来源:ActionController.java

示例6: getParamsOrHeadersMap

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
private HashMap<String, String> getParamsOrHeadersMap(JSONArray array) {
    HashMap<String, String> resultMap = new HashMap<>();
    if (null != array && array.size() > 0) {
        int loop = 0;
        while (loop < array.size()) {
            JSONObject jsonObject = array.getJSONObject(loop);
            resultMap.put(jsonObject.getString("name"), jsonObject.getString("value"));
            loop++;
        }
    }
    return resultMap;
}
 
开发者ID:melonlee,项目名称:PowerApi,代码行数:13,代码来源:AutoTestWorkConsumer.java

示例7: tap

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
private static boolean tap(JSONArray actions) throws Exception {
    for (int i = 0; i < actions.size(); i++) {
        JSONObject action = actions.getJSONObject(i);
        if(!tap(action)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:10,代码来源:ActionController.java

示例8: convert

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Override
public ArrayList<MultipleItemEntity> convert() {


    final JSONArray array = JSON.parseObject(getJsonData()).getJSONArray("data");
    final int size = array.size();
    for (int i = 0; i < size; i++) {

        final JSONObject data = array.getJSONObject(i);
        final int id = data.getInteger("id");
        final String name = data.getString("name");
        final String phone = data.getString("phone");
        final String address = data.getString("address");
        final boolean isDefault = data.getBoolean("default");

        final MultipleItemEntity entity = MultipleItemEntity.builder()
                .setItemType(AddressItemType.ITEM_ADDRESS)
                .setField(MultipleFields.ID, id)
                .setField(MultipleFields.NAME, name)
                .setField(MultipleFields.TAG, isDefault)
                .setField(AddressItemFields.PHONE, phone)
                .setField(AddressItemFields.ADDRESS, address)
                .build();

        ENTITIES.add(entity);

    }

    return ENTITIES;
}
 
开发者ID:remerber,项目名称:FastEc,代码行数:31,代码来源:AddressDataConverter.java

示例9: queryOne

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
/**
 * 查询成功时,结果为null或json。
 */
public JResponse queryOne(WObject wObject, DBSource dbSource, AdvancedQuery advancedQuery) {
    QuerySettings querySettings = new QuerySettings();
    querySettings.setLimit(1).setSkip(0);
    JResponse jResponse = advancedQuery(wObject, dbSource, advancedQuery, querySettings);
    if (jResponse.isSuccess()) {
        JSONArray array = jResponse.getResult();
        JSONObject jsonObject = array.size() > 0 ? array.getJSONObject(0) : null;
        jResponse.setResult(jsonObject);
    }
    return jResponse;
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:15,代码来源:DBCommon.java

示例10: convert

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
final List<SectionBean> convert(String json) {
    final List<SectionBean> dataList = new ArrayList<>();
    final JSONArray dataArray = JSON.parseObject(json).getJSONArray("data");

    final int size = dataArray.size();
    for (int i = 0; i < size; i++) {
        final JSONObject data = dataArray.getJSONObject(i);
        final int id = data.getInteger("id");
        final String title = data.getString("section");

        //添加title
        final SectionBean sectionTitleBean = new SectionBean(true, title);
        sectionTitleBean.setId(id);
        sectionTitleBean.setIsMore(true);
        dataList.add(sectionTitleBean);

        final JSONArray goods = data.getJSONArray("goods");
        //商品内容循环
        final int goodSize = goods.size();
        for (int j = 0; j < goodSize; j++) {
            final JSONObject contentItem = goods.getJSONObject(j);
            final int goodsId = contentItem.getInteger("goods_id");
            final String goodsName = contentItem.getString("goods_name");
            final String goodsThumb = contentItem.getString("goods_thumb");
            //获取内容
            final SectionContentItemEntity itemEntity = new SectionContentItemEntity();
            itemEntity.setGoodsId(goodsId);
            itemEntity.setGoodsName(goodsName);
            itemEntity.setGoodsThumb(goodsThumb);
            //添加内容
            dataList.add(new SectionBean(itemEntity));
        }
        //商品内容循环结束
    }
    //Section循环结束

    return dataList;
}
 
开发者ID:remerber,项目名称:FastEc,代码行数:39,代码来源:SectionDataConverter.java

示例11: getMemMetrics

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
/**
 * 内存
 * @param containerName
 * @param container
 * @return
 * @throws IOException
 */
private List<CollectObject> getMemMetrics(String containerName,JSONObject container,JSONObject machineInfo) throws IOException {
    List<CollectObject> collectObjectList = new ArrayList<>();

    boolean hasMemory = container.getJSONObject("spec").getBoolean("has_memory");
    collectObjectList.add(new CollectObject(containerName,"has_memory",hasMemory ? "1" : "0",""));

    if(hasMemory){
        long machineMemory = machineInfo.getLong("memory_capacity");//机器总内存
        long limitMemory = container.getJSONObject("spec").getJSONObject("memory").getLong("limit");//容器的内存限制大小
        if(limitMemory > machineMemory || limitMemory < 0){
            //若内存限制大于机器总内存或小于0,使用机器总内存为总内存大小
            limitMemory = machineMemory;
        }
        JSONArray stats = container.getJSONArray("stats");
        int count = stats.size();
        JSONObject stat = stats.getJSONObject(count - 1);
        JSONObject memory = stat.getJSONObject("memory");

        long usage = memory.getLong("usage");
        long cache = memory.getLong("cache");

        collectObjectList.add(new CollectObject(containerName,"mem.size.usage", String.valueOf(Maths.div(usage,1024 * 1024)),""));
        collectObjectList.add(new CollectObject(containerName,"mem.size.cache", String.valueOf(Maths.div(cache,1024 * 1024)),""));
        collectObjectList.add(new CollectObject(containerName,"mem.usage.rate", String.valueOf(Maths.div(usage,limitMemory,5) * 100),""));
        collectObjectList.add(new CollectObject(containerName,"mem.cache.rate", String.valueOf(Maths.div(cache,limitMemory,5) * 100),""));

    }
    return collectObjectList;
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:37,代码来源:DockerMetrics.java

示例12: scan

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
/**
 * 定时扫描远程配置信息
 */
private boolean scan() {

    String listUrl = url + "/list";
    String jsonString = httpGet(listUrl);

    if (StringUtils.isBlank(jsonString)) {
        LogKit.error("can not get remote config info,plase check url : " + listUrl);
        return false;
    }

    JSONArray jsonArray = null;
    try {
        jsonArray = JSON.parseArray(jsonString);
    } catch (Throwable ex) {
        LogKit.error("can not parse json : \n" + jsonString + "\n\nfrom url : " + listUrl, ex);
        return false;
    }

    for (int i = 0; i < jsonArray.size(); i++) {
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        curScan.put(jsonObject.getString("id"), jsonObject.getString("version"));
    }

    return true;

}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:30,代码来源:ConfigRemoteReader.java

示例13: parseArray

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
public static LinkedHashMap<String,BundleListing.BundleInfo> parseArray(String listingStr,LinkedHashMap<String,BundleListing.BundleInfo>currentBundleInfo) throws Exception{
    LinkedHashMap<String,BundleListing.BundleInfo> infos= new LinkedHashMap<>();
    JSONArray array = JSON.parseArray(listingStr);
    for(int x=0; x<array.size(); x++){
        JSONObject object = array.getJSONObject(x);
        BundleListing.BundleInfo info = new BundleListing.BundleInfo();
        info.setName(object.getString("name"));
        info.setPkgName(object.getString("pkgName"));
        info.setApplicationName(object.getString("applicationName"));
        info.setVersion(object.getString("version"));
        info.setDesc(object.getString("desc"));
        info.setUrl(object.getString("url"));
        info.setMd5(object.getString("md5"));
        String uniqueTag = object.getString("unique_tag");
        if(StringUtils.isEmpty(uniqueTag)){
            throw new IOException("uniqueTag is empty");
        }
        info.setUnique_tag(object.getString("unique_tag"));
        if (currentBundleInfo==null) {
            info.setCurrent_unique_tag(info.getUnique_tag());
        }else {
            if (currentBundleInfo.get(info.getPkgName())!= null){
                info.setCurrent_unique_tag(currentBundleInfo.get(info.getPkgName()).getUnique_tag());
            }
        }

        infos.put(info.getPkgName(),info);

    }
    return infos.size()>0 ? infos : null;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:32,代码来源:BundleListingUtil.java

示例14: getCpuMetrics

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
private List<CollectObject> getCpuMetrics(String containerName, JSONObject container) throws IOException, InterruptedException {
    List<CollectObject> collectObjectList = new ArrayList<>();

    boolean hasCpu = container.getJSONObject("spec").getBoolean("has_cpu");
    collectObjectList.add(new CollectObject(containerName,"has_cpu",hasCpu ? "1" : "0",""));
    if(hasCpu){
        JSONArray stats = container.getJSONArray("stats");
        int count = stats.size();
        if(count >= 2){
            JSONObject stat = stats.getJSONObject(count - 2);
            String timestamp = stat.getString("timestamp");
            long time = transNanoseconds(timestamp);

            JSONObject stat2 = stats.getJSONObject(count - 1);
            String timestamp2 = stat2.getString("timestamp");
            long time2 = transNanoseconds(timestamp2);

            if(time == 0 || time2 == 0){
                log.error("CPU利用率采集失败,时间钟转换失败");
                return new ArrayList<>();
            }

            JSONObject cpu = stat.getJSONObject("cpu");
            JSONObject usage = cpu.getJSONObject("usage");

            JSONObject cpu2 = stat2.getJSONObject("cpu");
            JSONObject usage2 = cpu2.getJSONObject("usage");

            long totalTime = time2 - time;

            long total = usage.getLong("total");
            long user = usage.getLong("user");
            long system = usage.getLong("system");

            long total2 = usage2.getLong("total");
            long user2 = usage2.getLong("user");
            long system2 = usage2.getLong("system");

            // 皮秒级别进行计算
            collectObjectList.add(new CollectObject(containerName,"total.cpu.usage.rate",String.valueOf(Maths.div(total2 - total,totalTime * 1000,5) * 100),""));
            collectObjectList.add(new CollectObject(containerName,"user.cpu.usage.rate",String.valueOf(Maths.div(user2 - user,totalTime * 1000,5) * 100),""));
            collectObjectList.add(new CollectObject(containerName,"system.cpu.usage.rate",String.valueOf(Maths.div(system2 - system,totalTime * 1000,5) * 100),""));
        }
    }

    return collectObjectList;
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:48,代码来源:DockerMetrics.java

示例15: getNetMetrics

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
private List<CollectObject> getNetMetrics(String containerName,JSONObject container){
    List<CollectObject> collectObjectList = new ArrayList<>();

    boolean hasNetwork = container.getJSONObject("spec").getBoolean("has_network");
    collectObjectList.add(new CollectObject(containerName,"has_network",hasNetwork ? "1" : "0",""));

    if(hasNetwork){
        JSONArray stats = container.getJSONArray("stats");
        int count = stats.size();
        JSONObject stat = stats.getJSONObject(count - 1);
        JSONObject network = stat.getJSONObject("network");
        JSONArray interfaces = network.getJSONArray("interfaces");
        for (Object ifObj : interfaces) {
            JSONObject ifJson = (JSONObject) ifObj;
            String ifName = ifJson.getString("name");
            String tag = "ifName=" + ifName;
            long rxBytes = ifJson.getLong("rx_bytes");
            long rxPackets = ifJson.getLong("rx_packets");
            long rxErrors = ifJson.getLong("rx_errors");
            long rxDropped = ifJson.getLong("rx_dropped");
            long txBytes = ifJson.getLong("tx_bytes");
            long txPackets = ifJson.getLong("tx_packets");
            long txErrors = ifJson.getLong("tx_errors");
            long txDropped = ifJson.getLong("tx_dropped");

            collectObjectList.add(new CollectObject(containerName,"net.if.in.bytes",String.valueOf(rxBytes),tag));
            collectObjectList.add(new CollectObject(containerName,"net.if.in.packets",String.valueOf(rxPackets),tag));
            collectObjectList.add(new CollectObject(containerName,"net.if.in.errors",String.valueOf(rxErrors),tag));
            collectObjectList.add(new CollectObject(containerName,"net.if.in.dropped",String.valueOf(rxDropped),tag));

            collectObjectList.add(new CollectObject(containerName,"net.if.in.speed.bytes",String.valueOf(rxBytes),tag,CounterType.COUNTER));
            collectObjectList.add(new CollectObject(containerName,"net.if.in.speed.packets",String.valueOf(rxPackets),tag,CounterType.COUNTER));
            collectObjectList.add(new CollectObject(containerName,"net.if.in.speed.errors",String.valueOf(rxErrors),tag,CounterType.COUNTER));
            collectObjectList.add(new CollectObject(containerName,"net.if.in.speed.dropped",String.valueOf(rxDropped),tag,CounterType.COUNTER));

            collectObjectList.add(new CollectObject(containerName,"net.if.out.bytes",String.valueOf(txBytes),tag));
            collectObjectList.add(new CollectObject(containerName,"net.if.out.packets",String.valueOf(txPackets),tag));
            collectObjectList.add(new CollectObject(containerName,"net.if.out.errors",String.valueOf(txErrors),tag));
            collectObjectList.add(new CollectObject(containerName,"net.if.out.dropped",String.valueOf(txDropped),tag));

            collectObjectList.add(new CollectObject(containerName,"net.if.out.speed.bytes",String.valueOf(txBytes),tag,CounterType.COUNTER));
            collectObjectList.add(new CollectObject(containerName,"net.if.out.speed.packets",String.valueOf(txPackets),tag,CounterType.COUNTER));
            collectObjectList.add(new CollectObject(containerName,"net.if.out.speed.errors",String.valueOf(txErrors),tag,CounterType.COUNTER));
            collectObjectList.add(new CollectObject(containerName,"net.if.out.speed.dropped",String.valueOf(txDropped),tag,CounterType.COUNTER));
        }
    }

    return collectObjectList;
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:50,代码来源:DockerMetrics.java


注:本文中的com.alibaba.fastjson.JSONArray.getJSONObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。