net.sf.json.JSONException类的使用及代码示例

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

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

JSONException介绍

暂无

代码示例

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

/**
 * @param str a JSON array representation of a list of {@link AuthorityURLInfo} objects
 * @return the list of parsed authrority URL from the argument JSON array
 * @throws IllegalArgumentException if {@code str} can't be parsed to a JSONArray
 */
public static List<AuthorityURLInfo> fromString(String str) throws IllegalArgumentException {
  try {
    final JSONArray array;
    array = JSONArray.fromObject(str);
    final int size = array.size();
    List<AuthorityURLInfo> list = new ArrayList<AuthorityURLInfo>(size);
    JSONObject jsonAuth;
    for (int i = 0; i < size; i++) {
      jsonAuth = array.getJSONObject(i);
      AuthorityURL auth = new AuthorityURL();
      auth.setName(jsonAuth.getString(NAME));
      auth.setHref(jsonAuth.getString(HREF));
      list.add(auth);
    }
    return list;
  } catch (JSONException e) {
    throw new IllegalArgumentException(e.getMessage(), e);
  }
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

protected void CommonConfigFromJsonObject(JSONObject inputDetail) throws LogException {
  try {
    if (inputDetail.has(Consts.CONST_CONFIG_INPUTDETAIL_PRIORITY))
      this.priority = inputDetail.getInt(Consts.CONST_CONFIG_INPUTDETAIL_PRIORITY);
    else
      this.priority = 0;
    if (inputDetail.has(Consts.CONST_CONFIG_INPUTDETAIL_MERGETYPE))
      this.mergeType = inputDetail.getString(Consts.CONST_CONFIG_INPUTDETAIL_MERGETYPE);
    else
      JSONArray sensitiveKeysArray = inputDetail.getJSONArray(Consts.CONST_CONFIG_INPUTDETAIL_SENSITIVEKEYS);
      SensitiveKey sensitiveKey = new SensitiveKey();
      for (int index = 0; index < sensitiveKeysArray.size(); index++) {
        sensitiveKey.FromJsonString(sensitiveKeysArray.getJSONObject(index).toString());
        sensitiveKeys.add(sensitiveKey);
    throw new LogException("FailToGenerateInputDetail", e.getMessage(), e, "");

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonObject(JSONObject dict) throws LogException {
  try {		
    setTitle(dict.getString("title"));
    setType(dict.getString("type"));
    JSONObject searchJson = dict.getJSONObject("search");
    setRawSearchAttr(searchJson.toString());
    setLogstore(searchJson.getString("logstore"));
      JSONArray xAxisArray = displayJson.getJSONArray("xAxis");
      ArrayList<String> xAxisArrayList = new ArrayList<String>();
      for (int index = 0; index != xAxisArray.size(); index++) {
        xAxisArrayList.add(xAxisArray.getString(index));
      ArrayList<String> yAxisArrayList = new ArrayList<String>();
      JSONArray yAxisArray = displayJson.getJSONArray("yAxis");
      for (int index = 0; index != yAxisArray.size(); index++) {
        yAxisArrayList.add(yAxisArray.getString(index));
    throw new LogException("FailedToGenerateChart",  e.getMessage(), e, "");

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonString(String configString) throws LogException {
    try {
      JSONObject dict = JSONObject.fromObject(configString);
      FromJsonObject(dict);
    } catch (JSONException e) {
      throw new LogException("FailToGenerateConfig",  e.getMessage(), e, "");
    }
  }
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

@Override
  public void FromJsonObject(JSONObject storageDetail) throws LogException {
    try {
      JSONObject storage = storageDetail.getJSONObject("storage");
      setmStorageFormat(storage.getString("format"));
      JSONObject detail = storage.getJSONObject("detail");
      JSONArray columns = detail.getJSONArray("columns");
      ArrayList<String> column = new ArrayList<String>();
      for (int index = 0; index < columns.size(); index++) {
        column.add(columns.getString(index));
      }
      setmStorageColumns(column);
      setDelimiter(detail.getString("delimiter"));
      setQuote(detail.getString("quote"));
      setNullIdentifier(detail.getString("nullIdentifier"));
      setHeader(detail.getBoolean("header"));
    } catch (JSONException ex) {
      throw new LogException("FailToParseOssShipperCsvStorageDetail",
          ex.getMessage(), ex, "");
    }
  }
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

@Override
  public void FromJsonObject(JSONObject storageDetail) throws LogException {
    try {
      JSONObject storage = storageDetail.getJSONObject("storage");
      setmStorageFormat(storage.getString("format"));
      JSONObject detail = storage.getJSONObject("detail");
      JSONArray columns = detail.getJSONArray("columns");
      ArrayList<OssShipperStorageColumn> column = new ArrayList<OssShipperStorageColumn>();
      for (int index = 0; index < columns.size(); index++) {
        column.add(new OssShipperStorageColumn(columns.getJSONObject(index).getString("name"), columns.getJSONObject(index).getString("type")));
      }
      setmStorageColumns(column);
    } catch (JSONException ex) {
      throw new LogException("FailToParseOssShipperParquetStorageDetail",
          ex.getMessage(), ex, "");
    }
  }
}

代码示例来源:origin: hudson.plugins/project-inheritance

if (!json.has(key)) {
    log.warning("Got submission of broken version config form.");
    return;
  JSONArray vArr = json.getJSONArray("versionID");
  JSONArray dArr = json.getJSONArray("description");
  JSONArray sArr = json.getJSONArray("stable");
  if (vArr.size() != dArr.size() || vArr.size() != sArr.size()) {
    log.warning("Field in version config form differ in length.");
    return;
pw.println("JSON=" + req.getSubmittedForm());
pw.println();
e.printStackTrace(pw);

代码示例来源:origin: com.aliyun.openservices/aliyun-log

protected ArrayList<Shard> ExtractShards(JSONArray array, String requestId)
    throws LogException {
  ArrayList<Shard> shards = new ArrayList<Shard>();
  try {
    for (int i = 0; i < array.size(); i++) {
      JSONObject shardDict = array.getJSONObject(i);
      int shardId = shardDict.getInt("shardID");
      String status = shardDict.getString("status");
      String begin = shardDict.getString("inclusiveBeginKey");
      String end = shardDict.getString("exclusiveEndKey");
      int createTime = shardDict.getInt("createTime");
      Shard shard = new Shard(shardId, status, begin, end, createTime);
      if (shardDict.containsKey("serverIp"))
      {
        shard.setServerIp(shardDict.getString("serverIp"));
      }
      shards.add(shard);
    }
  } catch (JSONException e) {
    throw new LogException(ErrorCodes.BAD_RESPONSE,
        "The response is not valid shard json array string : "
            + array.toString() + e.getMessage(), e, requestId);
  }
  return shards;
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonObject(JSONObject groupAttribute) throws LogException {
  try {
    this.externalName = groupAttribute.getString("externalName");
    this.groupTopic = groupAttribute.getString("groupTopic");
  } catch (JSONException e) {
    throw new LogException("FailToGenerateGroupAttribute", e.getMessage(), e, "");
  }
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonObject(JSONObject dict) throws LogException {
  try {
    setDashboardName(dict.getString("dashboardName"));
    setDescription(dict.getString("description"));
    if (dict.has("displayName"))
      setDisplayName(dict.getString("displayName"));
    ArrayList<Chart> chartList = new ArrayList<Chart>();
    try {
      JSONArray chartJsonArray = dict.getJSONArray("charts");
      for (int index = 0; index != chartJsonArray.size(); index++) {
        Chart chart = new Chart();
        chart.FromJsonObject(chartJsonArray.getJSONObject(index));
        chartList.add(chart);
      }
    } catch (JSONException e) {
      // ignore
    }
    setChartList(chartList);
    
  } catch (JSONException e) {
    throw new LogException("FailToGenerateDashboard",  e.getMessage(), e, "");
  }
}
public void FromJsonString(String dashboardString) throws LogException {

代码示例来源:origin: i-m-c/jenkins-inheritance-plugin

this.enableCreation = json.getBoolean("enableCreation");
} catch (JSONException ex) {
  this.enableCreation = false;
  this.triggerOnChange = json.getBoolean("triggerOnChange");
} catch (JSONException ex) {
  this.triggerOnChange = false;
  this.triggerOnStartup = json.getBoolean("triggerOnStartup");
} catch (JSONException ex) {
  this.triggerOnStartup = false;
  Object obj = json.get("creationClasses");
  if (obj == null) {
    throw new JSONException("No such key: creationClasses");
  Object obj = json.get("matings");
  if (obj == null) {
    throw new JSONException("No such key: matings");

代码示例来源:origin: QihooTest/Leo

/**
 * 把map表转换为json格式字符串,转换失败返回null
 * @param map
 * @return String
 */
public static String getJsonStrFromMap(Map<String, String> map) {
  JSONObject oneResult = new JSONObject();
  try {
    oneResult = JSONObject.fromObject(map);
  } catch (JSONException e) {
    log.error("从map表:" + map.toString() + "转换为json字符串出错");
    log.error(e.getMessage());
    return null;
  }
  return oneResult.toString();
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonObject(JSONObject dict) throws LogException {
  try {		
    setSavedSearchName(dict.getString(Consts.CONST_SAVEDSEARCH_NAME));
    setSearchQuery(dict.getString(Consts.CONST_SAVEDSEARCH_QUERY));
    setLogstore(dict.getString(Consts.CONST_SAVEDSEARCH_LOGSTORE));
    setTopic(dict.getString(Consts.CONST_SAVEDSEARCH_TOPIC));
    if (dict.has(Consts.CONST_SAVEDSEARCH_DISPLAYNAME))
      setDisplayName(dict.getString(Consts.CONST_SAVEDSEARCH_DISPLAYNAME));
    setRawSavedSearchAttr(dict.toString());
  } catch (JSONException e) {
    throw new LogException("FailToGenerateSavedSearch",  e.getMessage(), e, "");
  }
}
public void FromJsonString(String savedSearchString) throws LogException {

代码示例来源:origin: bioinformatics-ua/dicoogle

JSONObject data = JSONObject.fromObject(dataString);
  queryString = data.getString("queryString");
  if (queryString == null) {
    resp.sendError(
  arr = data.getJSONArray("extraFields");
  if (arr.isEmpty()) {
    resp.sendError(403,
        "No fields no suplied: Please fill the field \"extraFiekds\" in \"JSON-DATA\"");
} catch (JSONException ex) {
  resp.sendError(400,
      "Error parsing the JSON String: " + ex.toString());
  return;
    resp.getOutputStream());
if (arr.isEmpty()) {
  PluginController.getInstance().queryAll(task, queryString, fields);
} else {

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonObj(JSONObject obj) throws LogException {
  try {
    this.mOdpsEndPoint = obj.getString("odpsEndpoint");
    this.mOdpsProject = obj.getString("odpsProject");
    this.mOdpsTable = obj.getString("odpsTable");
    this.mLogFieldsList = FromJsonArray(obj.getJSONArray("fields"));
    this.mPartitionColumn = FromJsonArray(obj.getJSONArray("partitionColumn"));
    this.mPartitionTimeFormat = obj.getString("partitionTimeFormat");
    this.mBufferInterval = obj.getInt("bufferInterval");
  } catch (JSONException e) {
    throw new LogException("FailToParseOssShipperConfig",
        e.getMessage(), e, "");
  }
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonObject(JSONObject inputDetail) throws LogException {
  try {
    LocalFileConfigFromJsonObject(inputDetail);
    if (inputDetail.has(Consts.CONST_CONFIG_INPUTDETAIL_LOGBEGINREGEX))
      this.logBeginRegex = inputDetail.getString(Consts.CONST_CONFIG_INPUTDETAIL_LOGBEGINREGEX);
    else
      this.logBeginRegex = ".*";
    this.regex = inputDetail.getString(Consts.CONST_CONFIG_INPUTDETAIL_REGEX);
    SetKey(inputDetail.getJSONArray(Consts.CONST_CONFIG_INPUTDETAIL_KEY));
    if (inputDetail.has(Consts.CONST_CONFIG_INPUTDETAIL_CUSTOMIZEDFIELDS))
      this.customizedFields = inputDetail.getString(Consts.CONST_CONFIG_INPUTDETAIL_CUSTOMIZEDFIELDS);
  } catch (JSONException e) {
    throw new LogException("FailToGenerateInputDetail", e.getMessage(),
        e, "");
  }
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonObject(JSONObject dict) throws LogException {
  try {
    this.time = dict.getLong(LOGTAILPROFILE_TIME);
    this.source = dict.getString(LOGTAILPROFILE_SOURCE);
    this.ip = dict.getString(LOGTAILPROFILE_IP);
    this.alarmCount = dict.getInt(LOGTAILPROFILE_ALARMCOUNT);
    this.alarmType = dict.getString(LOGTAILPROFILE_ALARMTYPE);
    this.alarmMessage = dict.getString(LOGTAILPROFILE_ALARMMESSAGE);
    this.machineOS = dict.getString(LOGTAILPROFILE_MACHINEOS);
  } catch (JSONException e) {
    throw new LogException("FailToGenerateLogtailProfile", e.getMessage(), e, "");
  }
}

代码示例来源:origin: aliyun/aliyun-log-java-sdk

private ListEtlMetaResponse listEtlMeta(ListEtlMetaRequest request) throws LogException {
  Map<String, String> headParameter = GetCommonHeadPara(request.GetProject());
  Map<String, String> urlParameter = request.GetAllParams();
  String resourceUri = Consts.CONST_ETLMETA_URI;
  ResponseMessage response = SendData(request.GetProject(), HttpMethod.GET, resourceUri, urlParameter, headParameter);
  String requestId = GetRequestId(response.getHeaders());
  JSONObject object = parseResponseBody(response, requestId);
  ListEtlMetaResponse listResp = new ListEtlMetaResponse(response.getHeaders(), object.getInt(Consts.CONST_TOTAL));
  try {
    JSONArray items = object.getJSONArray("etlMetaList");
    for (int i = 0; i < items.size(); i++) {
      EtlMeta meta = new EtlMeta();
      meta.fromJsonObject(items.getJSONObject(i));
      listResp.addEtlMeta(meta);
    }
  } catch (JSONException e) {
    throw new LogException(ErrorCodes.BAD_RESPONSE, e.getMessage(), listResp.GetRequestId());
  }
  return listResp;
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public void FromJsonObject(JSONObject outputDetail) throws LogException {
  try {
    if (outputDetail.has("endpoint")) {
      this.endpoint = outputDetail.getString("endpoint");
    }
    this.logstoreName = outputDetail.getString("logstoreName");
  } catch (JSONException e) {
    throw new LogException("FailToGenerateOutputDetail",
        e.getMessage(), e, "");
  }
}

代码示例来源:origin: mbreese/couchdb4j

CouchResponse resp;
if (docId == null || docId.equals("")) {
 resp = session.post(name, doc.getJSONObject().toString());
 try {
  if (doc.getId() == null || doc.getId().equals("")) {
   doc.setId(resp.getBodyAsJSONObject().getString("id"));
  doc.setRev(resp.getBodyAsJSONObject().getString("rev"));
  e.printStackTrace();

相关文章

微信公众号

最新文章

更多