本文整理匯總了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;
}