本文整理汇总了Java中net.sf.json.JSONObject.get方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.get方法的具体用法?Java JSONObject.get怎么用?Java JSONObject.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleJson
import net.sf.json.JSONObject; //导入方法依赖的package包/类
public void handleJson(String jsonContent) throws Exception {
JSONArray array = JSONArray.fromObject(jsonContent);
JSONObject object = null;
int l = array.size();
for (int i = 0; i < l; i++) {
object = array.getJSONObject(i);
JSONObject obj1 = (JSONObject) object.get("data");
JSONObject obj2 = (JSONObject) obj1.get("archives");
for (int j = 0; j < 20; j++) {
JSONObject obj3 = (JSONObject) obj2.get(String.valueOf(j));
Bilibili video = new Bilibili();
video.setAid(Integer.parseInt(obj3.get("aid").toString()));
video.setTid(Integer.parseInt(obj3.get("tid").toString()));
video.setTname((obj3.get("tname")).toString());
video.setTitle((obj3.get("title")).toString());
video.setAuthor((obj3.get("author")).toString());
JSONObject obj4 = (JSONObject) obj3.get("stat");
video.setCoin(Integer.parseInt(obj4.get("coin").toString()));
video.setFavorite(Integer.parseInt(obj4.get("favorite").toString()));
JDBC.insertBilibiliData(conn, video);
}
}
}
示例2: getVideoNumber
import net.sf.json.JSONObject; //导入方法依赖的package包/类
public int getVideoNumber(String jsonContent) throws Exception {
JSONArray array = JSONArray.fromObject(jsonContent);
JSONObject object = null;
int l = array.size();
int videoNumber = 0;
for (int i = 0; i < l; i++) {
object = array.getJSONObject(i);
JSONObject obj1 = (JSONObject) object.get("data");
JSONObject obj2 = (JSONObject) obj1.get("page");
videoNumber = Integer.parseInt(obj2.get("count").toString());
}
return videoNumber;
}
示例3: service
import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
String spellRequestJSON = req.getReader().readLine();
JSONObject jsonReqObject = JSONObject.fromObject(spellRequestJSON);
jsonReqObject.get("params");
SpellcheckRequest spellRequest = new SpellcheckRequest();
spellRequest.setId(jsonReqObject.getString("id"));
spellRequest.setMethod(jsonReqObject.getString("method"));
SpellcheckRequestParams params = new SpellcheckRequestParams();
params.setLang(jsonReqObject.getJSONArray("params").getString(0));
Object object = jsonReqObject.getJSONArray("params").get(1);
if( object instanceof String )
{
params.setStringList(Collections.singletonList(object.toString()));
}
else if( object instanceof JSONArray )
{
params.setStringList((JSONArray) object);
}
spellRequest.setParams(params);
SpellcheckResponse spellResponse = spellcheckService.service(spellRequest);
resp.setHeader("Cache-Control", "no-cache, no-store"); //$NON-NLS-1$//$NON-NLS-2$
resp.setContentType("application/json"); //$NON-NLS-1$
resp.getWriter().write(parseResponseToJSON(spellResponse));
}
示例4: configure
import net.sf.json.JSONObject; //导入方法依赖的package包/类
@Override
public boolean configure(final StaplerRequest req, final JSONObject json) throws FormException {
Object sqsQueues = json.get("sqsQueues");
if (json.size() == 1) {
String key = json.keys().next().toString();
sqsQueues = json.getJSONObject(key).get("sqsQueues");
}
this.sqsQueues = req.bindJSONToList(SQSTriggerQueue.class, sqsQueues);
this.initQueueMap();
this.save();
EventBroker.getInstance().post(new ConfigurationChangedEvent());
return true;
}
示例5: spiderList
import net.sf.json.JSONObject; //导入方法依赖的package包/类
/**
* 爬虫访问列表,列出最近7天内,最近的100条爬虫记录
*/
@RequestMapping("spiderList")
@ResponseBody
public RequestLogItemListVO spiderList(HttpServletRequest request) throws LogException{
RequestLogItemListVO vo = new RequestLogItemListVO();
//当前10位时间戳
int currentTime = DateUtil.timeForUnix10();
String query = "siteid="+getSiteId();
String spider = null;
for (int i = 0; i < spiderNameArray.length; i++) {
if(spider == null){
spider = spiderNameArray[i];
}else{
spider = spider + " or " + spiderNameArray[i];
}
}
query = query + " and ("+spider+")";
//当月访问量统计
ArrayList<QueriedLog> jinriQlList = G.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 604800), currentTime, 0, 100, true);
JSONArray jsonArray = new JSONArray(); //某天访问量,pv
for (int i = 0; i < jinriQlList.size(); i++) {
LogItem li = jinriQlList.get(i).GetLogItem();
JSONObject json = JSONObject.fromObject(li.ToJsonString());
try {
json.put("logtimeString", DateUtil.dateFormat(json.getInt("logtime"), "MM-dd HH:mm"));
} catch (NotReturnValueException e) {
e.printStackTrace();
}
UserAgent ua = UserAgent.parseUserAgentString(json.getString("userAgent"));
json.put("os", ua.getOperatingSystem());
json.put("browser", ua.getBrowser());
if(ua.getOperatingSystem().getName().equals("Unknown")){
String userAgent = json.getString("userAgent");
//没有发现是哪个浏览器,那可能是爬虫
for (int j = 0; j < spiderNameArray.length; j++) {
if(userAgent.indexOf(spiderNameArray[j]) > -1){
json.put("os", spiderExplainArray[j]);
}
}
if(json.get("os") == null){
if(userAgent.equals("Mozilla")){
//忽略
}else{
System.out.println("未发现的useragent : "+json.toString());
}
}
}
jsonArray.add(json);
}
vo.setList(jsonArray);
AliyunLog.addActionLog(getSiteId(), "获取最近7天内,最近的100条访问记录");
return vo;
}
示例6: getRCJSON
import net.sf.json.JSONObject; //导入方法依赖的package包/类
private JSONObject getRCJSON(String[] rcodes) {
JSONObject result = new JSONObject();
for (String rcode : rcodes) {
int oldval = 0;
if (result.containsKey(rcode)) {
oldval = (Integer) result.get(rcode);
}
result.put(rcode, oldval + 1);
}
return result;
}