本文整理汇总了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.");
}
};
}
};
}