org.codehaus.jettison.json.JSONException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(153)

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

JSONException.getMessage介绍

暂无

代码示例

代码示例来源:origin: Netflix/Priam

object.put("num_files", fileCnt);
} catch (JSONException jse) {
  logger.info("Caught JSON Exception --> {}", jse.getMessage());

代码示例来源:origin: org.codehaus.jettison/jettison

public XMLStreamReader createXMLStreamReader(JSONTokener tokener) throws XMLStreamException {
  try {
    JSONObject root = createJSONObject(tokener);
    return new MappedXMLStreamReader(root, convention);
  } catch (JSONException e) {
    int column = e.getColumn();
    if (column == -1) {
      throw new XMLStreamException(e);
    } else {
      throw new XMLStreamException(e.getMessage(),
                     new ErrorLocation(e.getLine(), e.getColumn()),
                     e);
    }
  }
}

代码示例来源:origin: org.jboss.dna/dna-web-jcr-rest

public Response toResponse( JSONException exception ) {
  return Response.status(Status.BAD_REQUEST).entity(exception.getMessage()).build();
}

代码示例来源:origin: com.yahoo.vespa/clustercontroller-utils

@Override
public JSONObjectWrapper put(String key, Object value) {
  try{
    super.put(key, value);
    return this;
  } catch (JSONException e) {
    throw new NullPointerException(e.getMessage());
  }
}

代码示例来源:origin: GluuFederation/oxAuth

public PersistentJwt(String jwt) {
  try {
    load(jwt);
  } catch (JSONException e) {
    log.error(e.getMessage(), e);
  }
}

代码示例来源:origin: tadglines/Socket.IO-Java

@Override
public void onConnect(SocketIOOutbound outbound) {
  if (LOGGER.isLoggable(Level.FINE))
    LOGGER.fine(this + " connected.");
  this.outbound = outbound;
  try {
    send(new JSONObject().put("type", MessageType.ACK));
  } catch (JSONException e) {
    throw new RuntimeException(e.getMessage(), e);
  }
}

代码示例来源:origin: org.apache.apex/malhar-library

public void setTags(Set<String> tags)
{
 if (tags == null || tags.isEmpty()) {
  throw new IllegalArgumentException("tags can't be null or empty.");
 }
 try {
  JSONArray tagArray = new JSONArray(tags);
  schema.put(FIELD_SCHEMA_TAGS, tagArray);
 } catch (JSONException e) {
  Preconditions.checkState(false, e.getMessage());
  throw new RuntimeException(e);
 }
 schemaJSON = schema.toString();
}

代码示例来源:origin: com.couchbase.client/couchbase-client

/**
 * Parse a raw bucket config string into a {@link Bucket} configuration.
 *
 * @param bucketJson the raw JSON.
 * @return the parsed configuration.
 * @throws ParseException if the JSON could not be parsed properly.
 */
public Bucket parseBucket(String bucketJson) throws ParseException {
 try {
  return parseBucketFromJSON(new JSONObject(bucketJson), null);
 } catch (JSONException e) {
  throw new ParseException(e.getMessage(), 0);
 }
}

代码示例来源:origin: com.couchbase.client/couchbase-client

/**
 * Parse a raw bucket config and update an old bucket with the new infos.
 *
 * @param bucketJson the new JSON information.
 * @param currentBucket the current bucket to update.
 * @return the parsed configuration.
 * @throws ParseException if the JSON could not be parsed properly.
 */
public Bucket updateBucket(String bucketJson, Bucket currentBucket)
 throws ParseException {
 try {
  return parseBucketFromJSON(new JSONObject(bucketJson), currentBucket);
 } catch (JSONException e) {
  throw new ParseException(e.getMessage(), 0);
 }
}

代码示例来源:origin: wso2-attic/esb-connectors

private void generateResults(MessageContext messageContext, boolean resultStatus) {
    ResultPayloadCreater resultPayload = new ResultPayloadCreater();

    String responses = "<unzip><success>" + resultStatus + "</success></unzip>";

    try {
      OMElement element = resultPayload.performSearchMessages(responses);
      resultPayload.preparePayload(messageContext, element);
    } catch (XMLStreamException e) {
      log.error(e.getMessage());
      handleException(e.getMessage(), messageContext);
    } catch (IOException e) {
      log.error(e.getMessage());
      handleException(e.getMessage(), messageContext);
    } catch (JSONException e) {
      log.error(e.getMessage());
      handleException(e.getMessage(), messageContext);
    }
  }
}

代码示例来源:origin: com.couchbase.client/couchbase-client

/**
 * Parses a given /pools/{pool} JSON for the buckets URI.
 *
 * @param pool the actual pool object to attach to.
 * @param poolsJson the raw JSON for the pool response.
 * @throws ParseException if the JSON could not be parsed properly.
 */
public void parsePool(final Pool pool, final String poolsJson)
 throws ParseException {
 try {
  JSONObject buckets = new JSONObject(poolsJson).getJSONObject("buckets");
  URI bucketsUri = new URI(buckets.getString("uri"));
  pool.setBucketsUri(bucketsUri);
 } catch (JSONException e) {
  throw new ParseException(e.getMessage(), 0);
 } catch (URISyntaxException e) {
  throw new ParseException(e.getMessage(), 0);
 }
}

代码示例来源:origin: tadglines/Socket.IO-Java

void fire(String topic, String data) {
    for (Endpoint endpoint : endpoints.values())
      try {
        endpoint.send(new JSONObject().put("type", MessageType.PUBLISH).put("topic", topic).put("data", data));
      } catch (JSONException e) {
        throw new RuntimeException(e.getMessage(), e);
      }
  }
}

代码示例来源:origin: GluuFederation/oxAuth

public JSONObjectAsserter assertJsonObject() {
  try {
    return JSONObjectAsserter.of(new JSONObject(entity));
  } catch (JSONException e) {
    fail(e.getMessage() + "\nResponse was: " + entity, e);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: GluuFederation/oxAuth

@Parameters({"jwksPath"})
@Test
public void requestJwks(final String jwksPath) throws Exception {
  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + jwksPath).request();
  request.header("Accept", MediaType.APPLICATION_JSON);
  Response response = request.get();
  String entity = response.readEntity(String.class);
  showResponse("requestJwks", response, entity);
  assertEquals(response.getStatus(), 200, "Unexpected response code.");
  try {
    JSONObject jsonObj = new JSONObject(entity);
    assertTrue(jsonObj.has(JSON_WEB_KEY_SET), "Unexpected result: keys not found");
    JSONArray keys = jsonObj.getJSONArray(JSON_WEB_KEY_SET);
    assertNotNull(keys, "Unexpected result: keys is null");
    assertTrue(keys.length() > 0, "Unexpected result: keys is empty");
  } catch (JSONException e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}

代码示例来源:origin: GluuFederation/oxAuth

@Parameters({"registerPath"})
@Test
public void requestClientRegistrationFail3(final String registerPath) throws Exception {
  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
  String registerRequestContent = null;
  try {
    RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app",
        Arrays.asList("https://client.example.com/cb#fail_fragment"));
    registerRequestContent = registerRequest.getJSONParameters().toString(4);
  } catch (JSONException e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
  Response response = request.post(Entity.json(registerRequestContent));
  String entity = response.readEntity(String.class);
  showResponse("requestClientRegistrationFail3", response, entity);
  assertEquals(response.getStatus(), 400, "Unexpected response code. " + entity);
  TestUtil.assertErrorResponse(entity);
}

代码示例来源:origin: GluuFederation/oxAuth

@Parameters({"registerPath"})
@Test
public void requestClientRegistrationFail1(final String registerPath) throws Exception {
  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
  String registerRequestContent = null;
  try {
    RegisterRequest registerRequest = new RegisterRequest(null, null, null);
    registerRequestContent = registerRequest.getJSONParameters().toString(4);
  } catch (JSONException e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
  Response response = request.post(Entity.json(registerRequestContent));
  String entity = response.readEntity(String.class);
  showResponse("requestClientRegistrationFail 1", response, entity);
  assertEquals(response.getStatus(), 400, "Unexpected response code. " + entity);
  TestUtil.assertErrorResponse(entity);
}

代码示例来源:origin: GluuFederation/oxAuth

@Parameters({"endSessionPath"})
@Test(enabled = true) // switched off test : WebApplicationException seems to not translated correctly into response by container and results in 500 error. See org.xdi.oxauth.session.ws.rs.EndSessionRestWebServiceImpl.endSession()
public void requestEndSessionFail1(final String endSessionPath) throws Exception {
  EndSessionRequest endSessionRequest = new EndSessionRequest(null, null, null);
  Builder request = ResteasyClientBuilder.newClient()
      .target(url.toString() + endSessionPath + "?" + endSessionRequest.getQueryString()).request();
  request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
  Response response = request.get();
  String entity = response.readEntity(String.class);
  showResponse("requestEndSessionFail1", response, entity);
  assertEquals(response.getStatus(), 400, "Unexpected response code.");
  assertNotNull(entity, "Unexpected result: " + entity);
  try {
    JSONObject jsonObj = new JSONObject(entity);
    assertTrue(jsonObj.has("error"), "The error type is null");
    assertTrue(jsonObj.has("error_description"), "The error description is null");
  } catch (JSONException e) {
    e.printStackTrace();
    fail(e.getMessage() + "\nResponse was: " + entity);
  }
}

代码示例来源:origin: GluuFederation/oxAuth

@Parameters({"registerPath"})
@Test
public void requestClientRegistrationFail2(final String registerPath) throws Exception {
  Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
  String registerRequestContent = null;
  try {
    RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", null); // Missing
    // redirect
    // URIs
    registerRequestContent = registerRequest.getJSONParameters().toString(4);
  } catch (JSONException e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
  Response response = request.post(Entity.json(registerRequestContent));
  String entity = response.readEntity(String.class);
  showResponse("requestClientRegistrationFail 2", response, entity);
  assertEquals(response.getStatus(), 400, "Unexpected response code. " + entity);
  TestUtil.assertErrorResponse(entity);
}

代码示例来源:origin: com.yahoo.vespa/clustercontroller-utils

public JsonHttpResult(HttpResult other) {
  super(other);
  if (other.getContent() == null) {
    setParsedJson(new JSONObject());
    return;
  }
  try{
    if (other.getContent() instanceof JSONObject) {
      setParsedJson((JSONObject) other.getContent());
    } else {
      setParsedJson(new JSONObject(other.getContent().toString()));
    }
  } catch (JSONException e) {
    failedParsing = true;
    setParsedJson(createErrorJson(e.getMessage(), other));
  }
}

代码示例来源:origin: com.netflix.pytheas/pytheas-api

public JSONObject toJSONObject() {
  JSONObject obj = new JSONObject();
  try {
    obj.put("title", title);
    obj.put("key",   key);
    obj.put("noLink", noLink);
    obj.put("mode",  mode);
    obj.put("expand", true);
    obj.put("children", getChildrenJSONArray());
  } catch (JSONException e) {
    try {
      obj.put("error", e.getMessage());
    } catch (JSONException e1) {
    }
  }
  return obj;
}

相关文章