com.alibaba.fastjson.JSONException类的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(657)

本文整理了Java中com.alibaba.fastjson.JSONException类的一些代码示例,展示了JSONException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONException类的具体详情如下:
包路径:com.alibaba.fastjson.JSONException
类名称:JSONException

JSONException介绍

暂无

代码示例

代码示例来源:origin: alibaba/fastjson

private void readAfter() {
  int state = context.state;
  int newStat = -1;
  switch (state) {
    case StartObject:
      newStat = PropertyKey;
      break;
    case PropertyKey:
      newStat = PropertyValue;
      break;
    case PropertyValue:
      newStat = PropertyKey;
      break;
    case ArrayValue:
      break;
    case StartArray:
      newStat = ArrayValue;
      break;
    default:
      throw new JSONException("illegal state : " + state);
  }
  if (newStat != -1) {
    context.state = newStat;
  }
}

代码示例来源:origin: hs-web/hsweb-framework

@ExceptionHandler(JSONException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
ResponseMessage handleException(JSONException exception) {
  logger.error(exception.getMessage(), exception);
  return ResponseMessage.error(400, "解析JSON失败");
}

代码示例来源:origin: GitLqr/LQRWeChat

return false;
} catch (JSONException e) {
  e.printStackTrace();
  return false;

代码示例来源:origin: sealtalk/sealtalk-android

return;
} catch (JSONException e) {
  e.printStackTrace();
  NLog.d(TAG, "getGroupMember occurs JSONException e=" + e.toString() + "groupID=" + groupID);
  return;

代码示例来源:origin: sealtalk/sealtalk-android

private List<Friend> pullFriends() throws HttpException {
  List<Friend> friendsList = null;
  UserRelationshipResponse userRelationshipResponse;
  try {
    userRelationshipResponse = action.getAllUserRelationship();
  } catch (JSONException e) {
    NLog.d(TAG, "pullFriends occurs JSONException e=" + e.toString());
    return null;
  }
  if (userRelationshipResponse != null && userRelationshipResponse.getCode() == 200) {
    List<UserRelationshipResponse.ResultEntity> list = userRelationshipResponse.getResult();
    if (list != null && list.size() > 0) {
      syncDeleteFriends();
      friendsList = addFriends(list);
    }
    mGetAllUserInfoState |= FRIEND;
  }
  return friendsList;
}

代码示例来源:origin: actframework/actframework

private void ensureJsonDtoGenerated(WebSocketContext context) {
  if (0 == fieldsAndParamsCount || !context.isJson()) {
    return;
  }
  Class<? extends JsonDto> dtoClass = jsonDTOClassManager.get(paramSpecs, handlerClass);
  if (null == dtoClass) {
    // there are neither fields nor params
    return;
  }
  try {
    JsonDto dto = JSON.parseObject(patchedJsonBody(context), dtoClass);
    context.attribute(JsonDto.CTX_ATTR_KEY, dto);
  } catch (JSONException e) {
    if (e.getCause() != null) {
      logger.warn(e.getCause(), "error parsing JSON data");
    } else {
      logger.warn(e, "error parsing JSON data");
    }
    throw new BadRequest(e.getCause());
  }
}

代码示例来源:origin: iflytek/Guitar

jo.put(key, value);
} catch (JSONException e) {
  e.printStackTrace();

代码示例来源:origin: sealtalk/sealtalk-android

NLog.d(TAG, "fetchGroups occurs HttpException e=" + e.toString() + "groupID=" + groupID);
} catch (JSONException e) {
  e.printStackTrace();
  NLog.d(TAG, "fetchGroups occurs JSONException e=" + e.toString() + "groupID=" + groupID);

代码示例来源:origin: sealtalk/sealtalk-android

private boolean fetchBlackList() throws HttpException {
  GetBlackListResponse blackListResponse;
  try {
    blackListResponse = action.getBlackList();
  } catch (JSONException e) {
    NLog.d(TAG, "fetchBlackList occurs JSONException e=" + e.toString());
    return true;
  }
  if (blackListResponse != null && blackListResponse.getCode() == 200) {
    List<GetBlackListResponse.ResultEntity> blackList = blackListResponse.getResult();
    if (blackList != null && blackList.size() > 0) {
      syncDeleteBlackList();
      addBlackList(blackList);
    }
    mGetAllUserInfoState |= BLACKLIST;
    return true;
  }
  return false;
}

代码示例来源:origin: org.actframework/act

private void ensureJsonDtoGenerated(WebSocketContext context) {
  if (0 == fieldsAndParamsCount || !context.isJson()) {
    return;
  }
  Class<? extends JsonDto> dtoClass = jsonDTOClassManager.get(paramSpecs, handlerClass);
  if (null == dtoClass) {
    // there are neither fields nor params
    return;
  }
  try {
    JsonDto dto = JSON.parseObject(patchedJsonBody(context), dtoClass);
    context.attribute(JsonDto.CTX_ATTR_KEY, dto);
  } catch (JSONException e) {
    if (e.getCause() != null) {
      logger.warn(e.getCause(), "error parsing JSON data");
    } else {
      logger.warn(e, "error parsing JSON data");
    }
    throw new BadRequest(e.getCause());
  }
}

代码示例来源:origin: com.alibaba/fastjson

public void setMaxBufSize(int maxBufSize) {
  if (maxBufSize < this.buf.length) {
    throw new JSONException("must > " + buf.length);
  }
  this.maxBufSize = maxBufSize;
}

代码示例来源:origin: iflytek/Guitar

jo.put(key, value);
} catch (JSONException e) {
  e.printStackTrace();

代码示例来源:origin: alibaba/fastjson

/**
 * Method that JAX-RS container calls to deserialize given value.
 */
public Object readFrom(Class<Object> type, //
            Type genericType, //
            Annotation[] annotations, //
            MediaType mediaType, //
            MultivaluedMap<String, String> httpHeaders, //
            InputStream entityStream) throws IOException, WebApplicationException {
  try {
    FastJsonConfig fastJsonConfig = locateConfigProvider(type, mediaType);
    return JSON.parseObject(entityStream,
        fastJsonConfig.getCharset(),
        genericType,
        fastJsonConfig.getParserConfig(),
        fastJsonConfig.getParseProcess(),
        JSON.DEFAULT_PARSER_FEATURE,
        fastJsonConfig.getFeatures());
  } catch (JSONException ex) {
    throw new WebApplicationException("JSON parse error: " + ex.getMessage(), ex);
  }
}

代码示例来源:origin: sealtalk/sealtalk-android

private boolean fetchFriends() throws HttpException {
  UserRelationshipResponse userRelationshipResponse;
  try {
    userRelationshipResponse = action.getAllUserRelationship();
  } catch (JSONException e) {
    NLog.d(TAG, "fetchFriends occurs JSONException e=" + e.toString());
    return true;
  }
  if (userRelationshipResponse != null && userRelationshipResponse.getCode() == 200) {
    List<UserRelationshipResponse.ResultEntity> list = userRelationshipResponse.getResult();
    if (list != null && list.size() > 0) {
      syncDeleteFriends();
      addFriends(list);
    }
    mGetAllUserInfoState |= FRIEND;
    return true;
  }
  return false;
}

代码示例来源:origin: actframework/actframework

private void ensureJsonDtoGenerated(ActionContext context) {
  if (0 == fieldsAndParamsCount || (!context.jsonEncoded() && !context.xmlEncoded())) {
    return;
  }
  Class<? extends JsonDto> dtoClass = jsonDTOClassManager.get(paramSpecs, controllerClass);
  if (null == dtoClass) {
    // there are neither fields nor params
    return;
  }
  try {
    JsonDto dto = JSON.parseObject(patchedJsonBody(context), dtoClass);
    if (null != dto) {
      patchDtoBeans(dto);
      cacheJsonDto(context, dto);
    }
  } catch (JSONException e) {
    if (e.getCause() != null) {
      warn(e.getCause(), "error parsing JSON data");
    } else {
      warn(e, "error parsing JSON data");
    }
    throw new BadRequest(e.getCause());
  }
}

代码示例来源:origin: com.alibaba/fastjson

public void parseFieldUnwrapped(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
    throw new JSONException("TODO");
  }
}

代码示例来源:origin: huangfangyi/FanXin

@Override
  public void run() {
    boolean isChange = false;
    try {
      JSONObject jsonObject = JSONObject.parseObject(groupName);
      JSONArray jsonArray = jsonObject.getJSONArray("jsonArray");
      for (int i = 0; i < jsonArray.size(); i++) {
        JSONObject userJson = jsonArray.getJSONObject(i);
        if (hxid.equals(userJson.getString("hxid"))) {
          jsonArray.remove(userJson);
          isChange = true;
        }
      }
      if (isChange) {
        jsonObject.put("jsonArray", jsonArray);
        Message message = hanlder.obtainMessage();
        Bundle bundle = new Bundle();
        bundle.putString("groupId", groupId);
        bundle.putString("groupName", jsonObject.toJSONString());
        message.setData(bundle);
        message.what = UPDATE_GROUP_NAME;
        message.sendToTarget();
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
}).start();

代码示例来源:origin: alibaba/fastjson

throw new WebApplicationException("Could not write JSON: " + ex.getMessage(), ex);

代码示例来源:origin: sealtalk/sealtalk-android

private boolean fetchGroups() throws HttpException {
  GetGroupResponse groupResponse;
  try {
    groupResponse = action.getGroups();
  } catch (JSONException e) {
    NLog.d(TAG, "fetchGroups occurs JSONException e=" + e.toString());
    return true;
  }
  if (groupResponse != null && groupResponse.getCode() == 200) {
    List<GetGroupResponse.ResultEntity> groupsList = groupResponse.getResult();
    if (groupsList != null && groupsList.size() > 0) {
      syncDeleteGroups();
      addGroups(groupsList);
    }
    mGetAllUserInfoState |= GROUPS;
    return true;
  }
  return false;
}

代码示例来源:origin: org.actframework/act

private void ensureJsonDtoGenerated(ActionContext context) {
  if (0 == fieldsAndParamsCount || (!context.jsonEncoded() && !context.xmlEncoded())) {
    return;
  }
  Class<? extends JsonDto> dtoClass = jsonDTOClassManager.get(paramSpecs, controllerClass);
  if (null == dtoClass) {
    // there are neither fields nor params
    return;
  }
  try {
    JsonDto dto = JSON.parseObject(patchedJsonBody(context), dtoClass);
    if (null != dto) {
      patchDtoBeans(dto);
      cacheJsonDto(context, dto);
    }
  } catch (JSONException e) {
    if (e.getCause() != null) {
      warn(e.getCause(), "error parsing JSON data");
    } else {
      warn(e, "error parsing JSON data");
    }
    throw new BadRequest(e.getCause());
  }
}

相关文章

微信公众号

最新文章

更多