本文整理匯總了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);
}
示例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();
}
}
示例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.");
}
};
}
};
}