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


Java JSONObject.parseArray方法代码示例

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


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

示例1: getObject

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
 * read the json file and transform into memory
 *
 * @return
 * @throws Exception
 */
public Map<String, Map<String, String>> getObject() throws Exception {
    Map<String, Map<String, String>> result = new ConcurrentHashMap<String, Map<String, String>>();
    String jsonString = readFromFile();
    JSONArray jsonArray = JSONObject.parseArray(jsonString);
    if (jsonArray != null) {
        for (Object schema : jsonArray) {
            JSONObject x = (JSONObject) schema;
            String schemaName = x.getString("schema");
            JSONArray viewList = x.getJSONArray("list");
            Map<String, String> schemaView = new ConcurrentHashMap<String, String>();
            for (Object view : viewList) {
                JSONObject y = (JSONObject) view;
                schemaView.put(y.getString("name"), y.getString("sql"));
            }
            result.put(schemaName, schemaView);
        }
    }
    return result;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:26,代码来源:FileSystemRepository.java

示例2: user

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
 * 用户菜单列表
 */
@RequestMapping("/user")
public R user() {
    List<SysMenuEntity> menuList = null;
    Set<String> permissions = sysMenuService.getUserPermissions(getUserId());
    ValueOperations<String, String> ops = this.template.opsForValue();
    String keyMenu = getUserId() + "_menuList";
    if (!template.hasKey(keyMenu)) {
        logger.debug("菜单从database读取");
        menuList = sysMenuService.getUserMenuList(getUserId());
        ops.set(keyMenu, JSON.toJSONString(menuList));
    } else {
        logger.debug("菜单从redis读取");
        menuList = JSONObject.parseArray(ops.get(keyMenu),SysMenuEntity.class);
    }

    return R.ok().put("menuList", menuList).put("permissions", permissions);
}
 
开发者ID:guolf,项目名称:pds,代码行数:21,代码来源:SysMenuController.java

示例3: getFrequencyMap

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public Map<String, Frequency> getFrequencyMap() {
    if (null == frequencyMap) {
        synchronized (this) {
            if (null == frequencyMap) {
                if (StringUtils.isEmpty(frequencyInfo)) {
                    frequencyMap = Collections.emptyMap();
                } else {
                    frequencyMap = new HashMap<>(1 << 4);
                    JSONArray array = JSONObject.parseArray(frequencyInfo);
                    for (Object object : array) {
                        JSONObject o = (JSONObject) object;
                        Frequency frequency = JSONObject.toJavaObject(o, Frequency.class);
                        StringBuilder sBuilder = new StringBuilder()
                                .append(frequency.getPath()).append(KEY_SEPERATOR)
                                .append(frequency.getVersion());
                        frequencyMap.put(sBuilder.toString(), frequency);
                    }
                }
            }
        }
    }
    return frequencyMap;
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:24,代码来源:AppInfo.java

示例4: getList

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public @NonNull static <T> List<T> getList(String json, Class<T> clazz) {
  List<T> result = null;
  try {
    result = JSONObject.parseArray(json, clazz);
  } catch (Exception e) {
    e.printStackTrace();
    result = new ArrayList<>();
  }
  return result;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:11,代码来源:WXJsonUtils.java

示例5: onMessage

import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type)
    throws IOException {
  if (type != WebSocket.PayloadType.TEXT) {
    WXLogUtils.w(
        "Websocket received unexpected message with payload of type "
        + type);
    return;
  }
  for (JSDebuggerCallback callback : mCallbacks.values()) {
    callback.onMessage(payload, type);
  }

  String message = null;
  try {
    message = payload.readUtf8();
    JSONObject jsonObject = JSONObject.parseObject(message);
    Object name = jsonObject.get("method");
    Object value = jsonObject.get("arguments");
    if (name == null || value == null) {
      return;
    }
    if (TextUtils.equals(name.toString(), "setLogLevel")) {
      JSONArray jsonArray = JSONObject.parseArray(value.toString());
      String level = jsonArray.get(0).toString();
      WXEnvironment.sLogLevel = LogLevel.valueOf(level.toUpperCase());
      WXLogUtils.v("into--[onMessage]setLogLevel");
    }
  } catch (Exception e) {

  } finally {
    payload.close();
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:35,代码来源:WXWebSocketManager.java


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