use of com.google.gson.JsonSyntaxException in project jphp by jphp-compiler.
the class JsonFunctions method json_decode.
public static Memory json_decode(Environment env, String json, boolean assoc, int depth) {
MemoryDeserializer memoryDeserializer = new MemoryDeserializer();
memoryDeserializer.setEnv(env);
GsonBuilder gsonBuilder = JsonExtension.createGsonBuilderForDecode(memoryDeserializer);
memoryDeserializer.setAssoc(assoc);
memoryDeserializer.setMaxDepth(depth);
Gson gson = gsonBuilder.create();
try {
env.setUserValue(JsonFunctions.class.getName() + "#error", null);
Memory r = gson.fromJson(json, Memory.class);
if (r == null)
return Memory.NULL;
else
return assoc ? r.toImmutable() : r;
} catch (MemoryDeserializer.MaxDepthException e) {
env.setUserValue(JsonFunctions.class.getName() + "#error", JsonConstants.JSON_ERROR_DEPTH);
} catch (JsonSyntaxException e) {
env.setUserValue(JsonFunctions.class.getName() + "#error", JsonConstants.JSON_ERROR_SYNTAX);
} catch (JsonParseException e) {
env.setUserValue(JsonFunctions.class.getName() + "#error", JsonConstants.JSON_ERROR_STATE_MISMATCH);
}
return Memory.NULL;
}
use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.
the class NearbyTimeLineDao method get.
public NearbyStatusListBean get() throws WeiboException {
Map<String, String> map = new HashMap<String, String>();
map.put("access_token", access_token);
map.put("lat", lat);
map.put("long", long_fix);
String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, URLHelper.NEARBY_STATUS, map);
try {
NearbyStatusListBean value = new Gson().fromJson(jsonData, NearbyStatusListBean.class);
if (value != null) {
return value;
}
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
}
return null;
}
use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.
the class OAuthDao method getOAuthUserInfo.
public UserBean getOAuthUserInfo() throws WeiboException {
String uidJson = getOAuthUserUIDJsonData();
String uid = "";
try {
JSONObject jsonObject = new JSONObject(uidJson);
uid = jsonObject.optString("uid");
} catch (JSONException e) {
AppLogger.e(e.getMessage());
}
Map<String, String> map = new HashMap<String, String>();
map.put("uid", uid);
map.put("access_token", access_token);
String url = URLHelper.USER_SHOW;
String result = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
Gson gson = new Gson();
UserBean user = new UserBean();
try {
user = gson.fromJson(result, UserBean.class);
} catch (JsonSyntaxException e) {
AppLogger.e(result);
}
return user;
}
use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.
the class FriendGroupDao method getGroup.
public GroupListBean getGroup() throws WeiboException {
String url = URLHelper.FRIENDSGROUP_INFO;
Map<String, String> map = new HashMap<String, String>();
map.put("access_token", access_token);
String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
Gson gson = new Gson();
GroupListBean value = null;
try {
value = gson.fromJson(jsonData, GroupListBean.class);
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
}
return value;
}
use of com.google.gson.JsonSyntaxException in project weiciyuan by qii.
the class FriendGroupTimeLineDao method getGSONMsgList.
public MessageListBean getGSONMsgList() throws WeiboException {
String json = getMsgListJson();
Gson gson = new Gson();
MessageListBean value = null;
try {
value = gson.fromJson(json, MessageListBean.class);
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
return null;
}
if (value != null && value.getItemList().size() > 0) {
TimeLineUtility.filterMessage(value);
}
return value;
}
Aggregations