本文整理汇总了Java中twitter4j.internal.org.json.JSONArray类的典型用法代码示例。如果您正苦于以下问题:Java JSONArray类的具体用法?Java JSONArray怎么用?Java JSONArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONArray类属于twitter4j.internal.org.json包,在下文中一共展示了JSONArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
private void init(JSONObject json) throws TwitterException {
try {
JSONArray indicesArray = json.getJSONArray("indices");
setStart(indicesArray.getInt(0));
setEnd(indicesArray.getInt(1));
if (!json.isNull("name")) {
this.name = json.getString("name");
}
if (!json.isNull("screen_name")) {
this.screenName = json.getString("screen_name");
}
id = z_T4JInternalParseUtil.getLong("id", json);
} catch (JSONException jsone) {
throw new TwitterException(jsone);
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:18,代码来源:UserMentionEntityJSONImpl.java
示例2: coordinatesAsGeoLocationArray
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
static GeoLocation[][] coordinatesAsGeoLocationArray(JSONArray coordinates) throws TwitterException {
try {
GeoLocation[][] boundingBox = new GeoLocation[coordinates.length()][];
for (int i = 0; i < coordinates.length(); i++) {
JSONArray array = coordinates.getJSONArray(i);
boundingBox[i] = new GeoLocation[array.length()];
for (int j = 0; j < array.length(); j++) {
JSONArray coordinate = array.getJSONArray(j);
boundingBox[i][j] = new GeoLocation(coordinate.getDouble(1), coordinate.getDouble(0));
}
}
return boundingBox;
} catch (JSONException jsone) {
throw new TwitterException(jsone);
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:17,代码来源:z_T4JInternalJSONImplFactory.java
示例3: getURLEntitiesFromJSON
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
/**
* Get URL Entities from JSON Object.
* returns URLEntity array by entities/[category]/urls/url[]
*
* @param json user json object
* @param category entities category. e.g. "description" or "url"
* @return URLEntity array by entities/[category]/urls/url[]
* @throws JSONException
* @throws TwitterException
*/
private static URLEntity[] getURLEntitiesFromJSON(JSONObject json, String category) throws JSONException, TwitterException {
if (!json.isNull("entities")) {
JSONObject entitiesJSON = json.getJSONObject("entities");
if (!entitiesJSON.isNull(category)) {
JSONObject descriptionEntitiesJSON = entitiesJSON.getJSONObject(category);
if (!descriptionEntitiesJSON.isNull("urls")) {
JSONArray urlsArray = descriptionEntitiesJSON.getJSONArray("urls");
int len = urlsArray.length();
URLEntity[] urlEntities = new URLEntity[len];
for (int i = 0; i < len; i++) {
urlEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i));
}
return urlEntities;
}
}
}
return null;
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:29,代码来源:UserJSONImpl.java
示例4: createUserList
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
static ResponseList<User> createUserList(JSONArray list, HttpResponse res, Configuration conf) throws TwitterException {
try {
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.clearThreadLocalMap();
}
int size = list.length();
ResponseList<User> users = new ResponseListImpl<User>(size, res);
for (int i = 0; i < size; i++) {
JSONObject json = list.getJSONObject(i);
User user = new UserJSONImpl(json);
users.add(user);
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(user, json);
}
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(users, list);
}
return users;
} catch (JSONException jsone) {
throw new TwitterException(jsone);
} catch (TwitterException te) {
throw te;
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:26,代码来源:UserJSONImpl.java
示例5: createDirectMessageList
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
static ResponseList<DirectMessage> createDirectMessageList(HttpResponse res, Configuration conf) throws TwitterException {
try {
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.clearThreadLocalMap();
}
JSONArray list = res.asJSONArray();
int size = list.length();
ResponseList<DirectMessage> directMessages = new ResponseListImpl<DirectMessage>(size, res);
for (int i = 0; i < size; i++) {
JSONObject json = list.getJSONObject(i);
DirectMessage directMessage = new DirectMessageJSONImpl(json);
directMessages.add(directMessage);
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(directMessage, json);
}
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(directMessages, list);
}
return directMessages;
} catch (JSONException jsone) {
throw new TwitterException(jsone);
} catch (TwitterException te) {
throw te;
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:27,代码来源:DirectMessageJSONImpl.java
示例6: AccountSettingsJSONImpl
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
private AccountSettingsJSONImpl(HttpResponse res, JSONObject json) throws TwitterException {
super(res);
try {
JSONObject sleepTime = json.getJSONObject("sleep_time");
SLEEP_TIME_ENABLED = getBoolean("enabled", sleepTime);
SLEEP_START_TIME = sleepTime.getString("start_time");
SLEEP_END_TIME = sleepTime.getString("end_time");
if (json.isNull("trend_location")) {
TREND_LOCATION = new Location[0];
} else {
JSONArray locations = json.getJSONArray("trend_location");
TREND_LOCATION = new Location[locations.length()];
for (int i = 0; i < locations.length(); i++) {
TREND_LOCATION[i] = new LocationJSONImpl(locations.getJSONObject(i));
}
}
GEO_ENABLED = getBoolean("geo_enabled", json);
LANGUAGE = json.getString("language");
ALWAYS_USE_HTTPS = getBoolean("always_use_https", json);
DISCOVERABLE_BY_EMAIL = getBoolean("discoverable_by_email", json);
TIMEZONE = new TimeZoneJSONImpl(json.getJSONObject("time_zone"));
} catch (JSONException e) {
throw new TwitterException(e);
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:26,代码来源:AccountSettingsJSONImpl.java
示例7: init
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
private void init(JSONObject json) throws TwitterException {
try {
JSONArray indicesArray = json.getJSONArray("indices");
setStart(indicesArray.getInt(0));
setEnd(indicesArray.getInt(1));
this.url = json.getString("url");
if (!json.isNull("expanded_url")) {
// sets expandedURL to url if expanded_url is null
// http://jira.twitter4j.org/browse/TFJ-704
this.expandedURL = json.getString("expanded_url");
}else{
this.expandedURL = url;
}
if (!json.isNull("display_url")) {
// sets displayURL to url if expanded_url is null
// http://jira.twitter4j.org/browse/TFJ-704
this.displayURL = json.getString("display_url");
}else{
this.displayURL = url;
}
} catch (JSONException jsone) {
throw new TwitterException(jsone);
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:27,代码来源:URLEntityJSONImpl.java
示例8: createStatusList
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
public static ResponseList<Status> createStatusList(HttpResponse res, Configuration conf) throws TwitterException {
try {
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.clearThreadLocalMap();
}
JSONArray list = res.asJSONArray();
int size = list.length();
ResponseList<Status> statuses = new ResponseListImpl<Status>(size, res);
for (int i = 0; i < size; i++) {
JSONObject json = list.getJSONObject(i);
Status status = new StatusJSONImpl(json);
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(status, json);
}
statuses.add(status);
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(statuses, list);
}
return statuses;
} catch (JSONException jsone) {
throw new TwitterException(jsone);
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:25,代码来源:StatusJSONImpl.java
示例9: parseStatuses
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
public static ResponseList<Status> parseStatuses(Configuration conf, JSONArray list) throws JSONException, TwitterException {
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.clearThreadLocalMap();
}
int size = list.length();
ResponseList<Status> statuses = new ResponseListImpl<Status>(size, null);
for (int i = 0; i < size; i++) {
JSONObject json = list.getJSONObject(i);
Status status = new StatusJSONImpl(json);
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(status, json);
}
statuses.add(status);
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(statuses, list);
}
return statuses;
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:20,代码来源:StatusJSONImpl.java
示例10: createUserListList
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
static ResponseList<UserList> createUserListList(HttpResponse res, Configuration conf) throws TwitterException {
try {
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.clearThreadLocalMap();
}
JSONArray list = res.asJSONArray();
int size = list.length();
ResponseList<UserList> users = new ResponseListImpl<UserList>(size, res);
for (int i = 0; i < size; i++) {
JSONObject userListJson = list.getJSONObject(i);
UserList userList = new UserListJSONImpl(userListJson);
users.add(userList);
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(userList, userListJson);
}
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(users, list);
}
return users;
} catch (JSONException jsone) {
throw new TwitterException(jsone);
} catch (TwitterException te) {
throw te;
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:27,代码来源:UserListJSONImpl.java
示例11: VideoInfoImpl
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
VideoInfoImpl(JSONObject jsonObject) throws TwitterException {
aspectRatio = new ArrayList<>();
variants = new ArrayList<>();
try {
if (jsonObject.has("aspect_ratio")) {
JSONArray aspectRationArray = jsonObject.getJSONArray("aspect_ratio");
for (int i = 0; i < aspectRationArray.length(); i++) {
aspectRatio.add(aspectRationArray.getInt(i));
}
}
if (jsonObject.has("duration_millis")) {
millis = jsonObject.getLong("duration_millis");
}
if (jsonObject.has("variants")) {
JSONArray variantJSONArray = jsonObject.getJSONArray("variants");
for (int i = 0; i < variantJSONArray.length(); i++) {
variants.add(new VariantImpl(variantJSONArray.getJSONObject(i)));
}
}
} catch (JSONException e) {
throw new TwitterException(e);
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:25,代码来源:MediaEntityJSONImpl.java
示例12: createLocationList
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
static ResponseList<Location> createLocationList(JSONArray list, boolean storeJSON) throws TwitterException {
try {
int size = list.length();
ResponseList<Location> locations =
new ResponseListImpl<Location>(size, null);
for (int i = 0; i < size; i++) {
JSONObject json = list.getJSONObject(i);
Location location = new LocationJSONImpl(json);
locations.add(location);
if (storeJSON) {
DataObjectFactoryUtil.registerJSONObject(location, json);
}
}
if (storeJSON) {
DataObjectFactoryUtil.registerJSONObject(locations, list);
}
return locations;
} catch (JSONException jsone) {
throw new TwitterException(jsone);
} catch (TwitterException te) {
throw te;
}
}
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:24,代码来源:LocationJSONImpl.java
示例13: ControlStreamInfo
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
ControlStreamInfo(StreamController controller, JSONObject json) throws TwitterException {
this.controller = controller;
try {
JSONObject info = json.getJSONObject("info");
includeFollowingsActivity = getBoolean("include_followings_activity", info);
includeUserChanges = getBoolean("include_user_changes", info);
replies = getRawString("replies", info);
with = getRawString("with", info);
JSONArray usersJSON = info.getJSONArray("users");
users = new StreamController.User[usersJSON.length()];
for (int i = 0; i < usersJSON.length(); i++) {
users[i] = this.controller.createUser(usersJSON.getJSONObject(i));
}
} catch (JSONException e) {
throw new TwitterException(e);
}
}
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:20,代码来源:ControlStreamInfo.java
示例14: init
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
private void init(JSONObject json) throws TwitterException {
try {
JSONObject follow = json.getJSONObject("follow");
JSONArray idList = follow.getJSONArray("friends");
ids = new long[idList.length()];
for (int i = 0; i < idList.length(); i++) {
try {
ids[i] = Long.parseLong(idList.getString(i));
} catch (NumberFormatException nfe) {
throw new TwitterException("Twitter API returned malformed response: " + json, nfe);
}
}
user = new User(follow.getJSONObject("user"));
previousCursor = z_T4JInternalParseUtil.getLong("previous_cursor", json);
nextCursor = z_T4JInternalParseUtil.getLong("next_cursor", json);
} catch (JSONException jsone) {
throw new TwitterException(jsone);
}
}
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:20,代码来源:StreamController.java
示例15: createSavedSearchList
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
static ResponseList<SavedSearch> createSavedSearchList(HttpResponse res, Configuration conf) throws TwitterException {
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.clearThreadLocalMap();
}
JSONArray json = res.asJSONArray();
ResponseList<SavedSearch> savedSearches;
try {
savedSearches = new ResponseListImpl<SavedSearch>(json.length(), res);
for (int i = 0; i < json.length(); i++) {
JSONObject savedSearchesJSON = json.getJSONObject(i);
SavedSearch savedSearch = new SavedSearchJSONImpl(savedSearchesJSON);
savedSearches.add(savedSearch);
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(savedSearch, savedSearchesJSON);
}
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(savedSearches, json);
}
return savedSearches;
} catch (JSONException jsone) {
throw new TwitterException(jsone.getMessage() + ":" + res.asString(), jsone);
}
}
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:25,代码来源:SavedSearchJSONImpl.java
示例16: FriendshipJSONImpl
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
FriendshipJSONImpl(JSONObject json) throws TwitterException {
super();
try {
id = getLong("id", json);
name = json.getString("name");
screenName = json.getString("screen_name");
JSONArray connections = json.getJSONArray("connections");
for (int i = 0; i < connections.length(); i++) {
String connection = connections.getString(i);
if ("following".equals(connection)) {
following = true;
} else if ("followed_by".equals(connection)) {
followedBy = true;
}
}
} catch (JSONException jsone) {
throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone);
}
}
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:20,代码来源:FriendshipJSONImpl.java
示例17: createFriendshipList
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
static ResponseList<Friendship> createFriendshipList(HttpResponse res, Configuration conf) throws TwitterException {
try {
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.clearThreadLocalMap();
}
JSONArray list = res.asJSONArray();
int size = list.length();
ResponseList<Friendship> friendshipList = new ResponseListImpl<Friendship>(size, res);
for (int i = 0; i < size; i++) {
JSONObject json = list.getJSONObject(i);
Friendship friendship = new FriendshipJSONImpl(json);
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(friendship, json);
}
friendshipList.add(friendship);
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(friendshipList, list);
}
return friendshipList;
} catch (JSONException jsone) {
throw new TwitterException(jsone);
} catch (TwitterException te) {
throw te;
}
}
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:27,代码来源:FriendshipJSONImpl.java
示例18: getURLEntitiesFromJSON
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
/**
* Get URL Entities from JSON Object.
* returns URLEntity array by entities/[category]/urls/url[]
*
* @param json user json object
* @param category entities category. e.g. "description" or "url"
* @return URLEntity array by entities/[category]/urls/url[]
* @throws JSONException
* @throws TwitterException
*/
private static URLEntity[] getURLEntitiesFromJSON(JSONObject json, String category) throws JSONException, TwitterException {
if (!json.isNull("entities")) {
JSONObject entitiesJSON = json.getJSONObject("entities");
if (!entitiesJSON.isNull(category)) {
JSONObject descriptionEntitiesJSON = entitiesJSON.getJSONObject(category);
if (!descriptionEntitiesJSON.isNull("urls")) {
JSONArray urlsArray = descriptionEntitiesJSON.getJSONArray("urls");
int len = urlsArray.length();
URLEntity[] urlEntities = new URLEntity[len];
for (int i = 0; i < len; i++) {
urlEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i));
}
return urlEntities;
}
}
}
return null;
}
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:29,代码来源:UserJSONImpl.java
示例19: createUserList
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
static ResponseList<User> createUserList(JSONArray list, HttpResponse res, Configuration conf) throws TwitterException {
try {
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.clearThreadLocalMap();
}
int size = list.length();
ResponseList<User> users =
new ResponseListImpl<User>(size, res);
for (int i = 0; i < size; i++) {
JSONObject json = list.getJSONObject(i);
User user = new UserJSONImpl(json);
users.add(user);
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(user, json);
}
}
if (conf.isJSONStoreEnabled()) {
DataObjectFactoryUtil.registerJSONObject(users, list);
}
return users;
} catch (JSONException jsone) {
throw new TwitterException(jsone);
} catch (TwitterException te) {
throw te;
}
}
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:27,代码来源:UserJSONImpl.java
示例20: AccountSettingsJSONImpl
import twitter4j.internal.org.json.JSONArray; //导入依赖的package包/类
private AccountSettingsJSONImpl(HttpResponse res, JSONObject json) throws TwitterException {
super(res);
try {
JSONObject sleepTime = json.getJSONObject("sleep_time");
SLEEP_TIME_ENABLED = getBoolean("enabled", sleepTime);
SLEEP_START_TIME = sleepTime.getString("start_time");
SLEEP_END_TIME = sleepTime.getString("end_time");
if (json.isNull("trend_location")) {
TREND_LOCATION = new Location[0];
} else {
JSONArray locations = json.getJSONArray("trend_location");
TREND_LOCATION = new Location[locations.length()];
for (int i = 0; i < locations.length(); i++) {
TREND_LOCATION[i] = new LocationJSONImpl(locations.getJSONObject(i));
}
}
GEO_ENABLED = getBoolean("geo_enabled", json);
LANGUAGE = json.getString("language");
ALWAYS_USE_HTTPS = getBoolean("always_use_https", json);
DISCOVERABLE_BY_EMAIL = getBoolean("discoverable_by_email", json);
TIMEZONE = new TimeZoneJSONImpl(json.getJSONObject("time_zone"));
SCREEN_NAME = json.getString("screen_name");
} catch (JSONException e) {
throw new TwitterException(e);
}
}
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:27,代码来源:AccountSettingsJSONImpl.java
注:本文中的twitter4j.internal.org.json.JSONArray类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论