當前位置: 首頁>>代碼示例>>Java>>正文


Java ExtendedJSONObject.getArray方法代碼示例

本文整理匯總了Java中org.mozilla.gecko.sync.ExtendedJSONObject.getArray方法的典型用法代碼示例。如果您正苦於以下問題:Java ExtendedJSONObject.getArray方法的具體用法?Java ExtendedJSONObject.getArray怎麽用?Java ExtendedJSONObject.getArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.gecko.sync.ExtendedJSONObject的用法示例。


在下文中一共展示了ExtendedJSONObject.getArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: tabFromJSONObject

import org.mozilla.gecko.sync.ExtendedJSONObject; //導入方法依賴的package包/類
public static Tab tabFromJSONObject(JSONObject o) throws NonArrayJSONException {
  ExtendedJSONObject obj = new ExtendedJSONObject(o);
  String title      = obj.getString("title");
  String icon       = obj.getString("icon");
  JSONArray history = obj.getArray("urlHistory");

  // Last used is inexplicably a string in seconds. Most of the time.
  long lastUsed = 0;
  Object lU = obj.get("lastUsed");
  if (lU instanceof Number) {
    lastUsed = ((Long) lU) * 1000L;
  } else if (lU instanceof String) {
    try {
      lastUsed = Long.parseLong((String) lU, 10) * 1000L;
    } catch (NumberFormatException e) {
      Logger.debug(TabsRecord.LOG_TAG, "Invalid number format in lastUsed: " + lU);
    }
  }
  return new Tab(title, icon, history, lastUsed);
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:21,代碼來源:TabsRecord.java

示例2: initFromPayload

import org.mozilla.gecko.sync.ExtendedJSONObject; //導入方法依賴的package包/類
@Override
protected void initFromPayload(ExtendedJSONObject payload) {
  this.histURI = (String) payload.get("histUri");
  this.title   = (String) payload.get("title");
  try {
    this.visits = payload.getArray("visits");
  } catch (NonArrayJSONException e) {
    Logger.error(LOG_TAG, "Got non-array visits in history record " + this.guid, e);
    this.visits = new JSONArray();
  }
}
 
開發者ID:mozilla-mobile,項目名稱:FirefoxData-android,代碼行數:12,代碼來源:HistoryRecord.java

示例3: getRecords

import org.mozilla.gecko.sync.ExtendedJSONObject; //導入方法依賴的package包/類
public Iterable<ServerReadingListRecord> getRecords() throws IOException, ParseException, UnexpectedJSONException {
  final ExtendedJSONObject body = jsonObjectBody();
  final JSONArray items = body.getArray("items");

  final int expected = getTotalRecords();
  final int actual = items.size();
  if (actual < expected) {
    Logger.warn(LOG_TAG, "Unexpected number of records. Got " + actual + ", expected " + expected);
  }

  return new Iterable<ServerReadingListRecord>() {
    @Override
    public Iterator<ServerReadingListRecord> iterator() {
      return new Iterator<ServerReadingListRecord>() {
        int position = 0;

        @Override
        public boolean hasNext() {
          return position < actual;
        }

        @Override
        public ServerReadingListRecord next() {
          final Object o = items.get(position++);
          return new ServerReadingListRecord(new ExtendedJSONObject((JSONObject) o));
        }

        @Override
        public void remove() {
          throw new RuntimeException("Cannot remove from iterator.");
        }
      };
    }
  };
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:36,代碼來源:ReadingListStorageResponse.java


注:本文中的org.mozilla.gecko.sync.ExtendedJSONObject.getArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。