本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
}