本文整理汇总了Java中com.alibaba.fastjson.JSONObject.getLongValue方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getLongValue方法的具体用法?Java JSONObject.getLongValue怎么用?Java JSONObject.getLongValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getLongValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doProcess
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Override
public final QCloudMsgResponse doProcess(String jsonBody,Map<String,Object> urlParams,String key) {
JSONObject jsonObject = JSON.parseObject(jsonBody);
String sign = jsonObject.getString("sign");
long t = jsonObject.getLongValue("t");
if (!isValid(t, key, sign)) {
return onInvalidMsg(jsonBody);
}
int eventType = jsonObject.getIntValue("event_type");
switch (eventType) {
case LiveMsgEventType.CUT_STREAM:
return onCutStream(JSON.parseObject(jsonBody, LiveMsgStreamEventDO.class));
case LiveMsgEventType.PUSH_STREAM:
return onPushStream(JSON.parseObject(jsonBody, LiveMsgStreamEventDO.class));
case LiveMsgEventType.RECORD_AV_CREATED:
return onAvRecordCreated(JSON.parseObject(jsonBody, LiveMsgAvRecordCreatedDO.class));
case LiveMsgEventType.SCREENSHOT_CREATED:
return onScreenshotCreated(JSON.parseObject(jsonBody, LiveMsgScreenshotCreatedDO.class));
default:
break;
}
return LiveMsgResponse.FAILED;
}
示例2: testExecute
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Test
public void testExecute() throws ExecutionException, InterruptedException {
ExecutorService exec = Executors.newCachedThreadPool();
bodyContent = LianJiaCrawler.doGet(dataUrl, agentHeaderArr);
jsonResult = JSON.parseObject(bodyContent, JsonResult.class);
System.out.println(">>> dataUrl jsonResult: " + jsonResult.toString());
if (200 == jsonResult.getStatus()) {
JSONArray jsonArray = (JSONArray) jsonResult.getData();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
Long id = jsonObject.getLongValue("id");
for (int j = 0; j < threadSize; j++) {
Future<String> future = exec.submit(new SecKillCallable(id,i + j));
LOGGER.debug(">>> i future.get(): ", future.get());
}
}
}
exec.shutdown();
}
示例3: loadPositions
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public void loadPositions(String json) {
if (StringHelper.isEmpty(json)) {
return;
}
Long inode = 0L, pos = 0L, number = 0L;
String file = "";
JSONArray positionRecords = JSONArray.parseArray(json);
for (int i = 0; i < positionRecords.size(); i++) {
JSONObject positionObject = (JSONObject) positionRecords.get(i);
inode = positionObject.getLong("inode");
pos = positionObject.getLong("pos");
file = positionObject.getString("file");
// add line number
number = positionObject.getLongValue("num");
for (Object v : Arrays.asList(inode, pos, file)) {
Preconditions.checkNotNull(v, "Detected missing value in position file. " + "inode: " + inode
+ ", pos: " + pos + ", path: " + file);
}
TailFile tf = tailFiles.get(inode);
try {
if (tf != null && tf.updatePos(file, inode, pos, number)) {
tailFiles.put(inode, tf);
}
else {
// add old tail file into memory
maybeReloadMap.put(inode, new Long[] { pos, number });
if (log.isDebugEnable()) {
log.debug(this, "add old&inInterrupt file: " + file + ", inode: " + inode + ", pos: " + pos);
}
}
}
catch (IOException e) {
log.err(this, "TailFile updatePos FAILED.", e);
}
}
}
示例4: getAnnouncements
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public static List<Announcement> getAnnouncements(String teamId, String announce, int limit) {
if (TextUtils.isEmpty(announce)) {
return null;
}
List<Announcement> announcements = new ArrayList<>();
try {
int count = 0;
JSONArray jsonArray = JSONArray.parseArray(announce);
for (int i = jsonArray.size() - 1; i >= 0; i--) {
JSONObject json = jsonArray.getJSONObject(i);
String id = json.getString(JSON_KEY_ID);
String creator = json.getString(JSON_KEY_CREATOR);
String title = json.getString(JSON_KEY_TITLE);
long time = json.getLongValue(JSON_KEY_TIME);
String content = json.getString(JSON_KEY_CONTENT);
announcements.add(new Announcement(id, teamId, creator, title, time, content));
if (++count >= limit) {
break;
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return announcements;
}
示例5: playUrl
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "playUrl", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
@ResponseBody
public ReturnT<JSONArray> playUrl(Model model, HttpServletRequest request, @RequestParam("uid") String uid) {
HeadPrinter.printHead(model);
JSONObject jsonObject1 = JSONObject.parseObject(uid);
long id = jsonObject1.getLongValue("uid");
String result = NetEaseClient.getPlayUrl(id);
JSONObject jsonObject = JSONObject.parseObject(result);
String ly = "";
JSONArray jsonArray = jsonObject.getJSONArray("data");
return new ReturnT(jsonArray, ly);
}
示例6: deserialze
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, java.lang.reflect.Type type, Object fieldName) {
JSONObject object = parser.parseObject();
long id = object.getLongValue("id");
return (T) Type.valueOf(id);
}