本文整理了Java中org.json.simple.parser.ParseException.getMessage()
方法的一些代码示例,展示了ParseException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ParseException.getMessage()
方法的具体详情如下:
包路径:org.json.simple.parser.ParseException
类名称:ParseException
方法名:getMessage
暂无
代码示例来源:origin: apache/drill
private void formatResponse(String result) {
JSONParser parser = new JSONParser();
Object status;
try {
status = parser.parse(result);
} catch (ParseException e) {
System.err.println("Invalid response received from AM");
if (opts.verbose) {
System.out.println(result);
System.out.println(e.getMessage());
}
return;
}
JSONObject root = (JSONObject) status;
showMetric("AM State", root, "state");
showMetric("Target Drillbit Count", root.get("summary"), "targetBitCount");
showMetric("Live Drillbit Count", root.get("summary"), "liveBitCount");
showMetric("Unmanaged Drillbit Count", root.get("summary"), "unmanagedCount");
showMetric("Blacklisted Node Count", root.get("summary"), "blackListCount");
showMetric("Free Node Count", root.get("summary"), "freeNodeCount");
}
代码示例来源:origin: apache/drill
if (opts.verbose) {
System.out.println(result);
System.out.println(e.getMessage());
代码示例来源:origin: GlowstoneMC/Glowstone
obj = JSONValue.parseWithException(json);
} catch (ParseException e) {
sender.sendMessage(ChatColor.RED + "Failed to parse JSON: " + e.getMessage());
return false;
代码示例来源:origin: larsgeorge/hbase-book
@Override
protected void map(LongWritable offset, Text value, Context context)
throws IOException, InterruptedException {
String line = value.toString();
try {
Object o = parser.parse(line);
} catch (ParseException e) {
if (skipBadLines) {
System.err.println("Bad line at offset: " + offset.get() +
":\n" + e.getMessage());
badLineCount.increment(1);
return;
} else {
throw new IOException(e);
}
}
}
}
代码示例来源:origin: apache/metron
/**
* Gets a message or messages from a String argument.
*
* @param arg0 The function argument is just a List.
* @return A list of messages.
*/
private List<JSONObject> getMessagesFromString(String arg0) {
List<JSONObject> messages = new ArrayList<>();
try {
Object parsedArg0 = parser.parse(arg0);
if (parsedArg0 instanceof JSONObject) {
// if the string only contains one message
messages.add((JSONObject) parsedArg0);
} else if (parsedArg0 instanceof JSONArray) {
// if the string contains multiple messages
JSONArray jsonArray = (JSONArray) parsedArg0;
for (Object item : jsonArray) {
messages.addAll(getMessages(item));
}
} else {
throw new IllegalArgumentException(format("invalid message: found '%s', expected JSONObject or JSONArray",
ClassUtils.getShortClassName(parsedArg0, "null")));
}
} catch (org.json.simple.parser.ParseException e) {
throw new IllegalArgumentException(format("invalid message: '%s'", e.getMessage()), e);
}
return messages;
}
}
代码示例来源:origin: larsgeorge/hbase-book
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
boolean next = lineRecordReader.nextKeyValue();
if (next) {
String line = lineRecordReader.getCurrentValue().toString();
try {
JSONObject json = (JSONObject) parser.parse(line);
String author = (String) json.get("author");
String link = (String) json.get("link");
} catch (ParseException e) {
if (skipBadLines) {
System.err.println("Bad line at offset: " +
lineRecordReader.getCurrentKey().get() +
":\n" + e.getMessage());
badLineCount++;
} else {
throw new IOException(e);
}
}
}
return next;
}
代码示例来源:origin: linkedin/indextank-engine
if(LOG_ENABLED) LOG.severe("PUT doc, parse input " + e.getMessage());
} catch (ParseException e) {
if(LOG_ENABLED) LOG.severe("PUT doc, parse input " + e.getMessage());
} catch (Exception e) {
if(LOG_ENABLED) LOG.severe("PUT doc " + e.getMessage());
代码示例来源:origin: linkedin/indextank-engine
if(LOG_ENABLED) LOG.severe("DELETE doc, parse input " + e.getMessage());
} catch (ParseException e) {
if(LOG_ENABLED) LOG.severe("DELETE doc, parse input " + e.getMessage());
} catch (Exception e) {
if(LOG_ENABLED) LOG.severe("DELETE doc " + e.getMessage());
代码示例来源:origin: jitsi/jitsi-videobridge
" could not parse JSON, message: %s", pe.getMessage());
logger.error(message);
response.getOutputStream().println(message);
代码示例来源:origin: jitsi/jitsi-videobridge
" conference: %s, could not parse" +
" JSON message: %s", target,
pe.getMessage());
logger.error(message);
response.getOutputStream().println(message);
代码示例来源:origin: com.adobe.ride/ride-core
/**
* Method to parse the response body into a JSONObject
*
* @param body String representation of the response body
* @return JSONObject
*/
protected static JSONObject parseResponseBody(String body) {
JSONObject returnObject = null;
try {
returnObject = (JSONObject) parser.parse(body);
} catch (ParseException e) {
logger.log(Level.SEVERE, e.getMessage());
}
return returnObject;
}
}
代码示例来源:origin: com.adobe.ride/ride-model-util
/**
* Method to sync the JSONObject type objectMetadata.
*
* @param dataTree
*/
private void refreshMetadata(JsonNode dataTree) {
String treeDump = dataTree.toString().replace("\\", "").replace("\"[", "[").replace("]\"", "]");
// strip backslashes and format arrays. A problem caused by the JsonNode string
// dump.
try {
objectMetadata = (JSONObject) parser.parse(treeDump);
} catch (ParseException e) {
logger.log(Level.SEVERE, e.getMessage());
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-httpfs
/**
* Convenience method that JSON Parses the <code>InputStream</code> of a
* <code>HttpURLConnection</code>.
*
* @param conn the <code>HttpURLConnection</code>.
*
* @return the parsed JSON object.
*
* @throws IOException thrown if the <code>InputStream</code> could not be
* JSON parsed.
*/
static Object jsonParse(HttpURLConnection conn) throws IOException {
try {
JSONParser parser = new JSONParser();
return parser.parse(
new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
} catch (ParseException ex) {
throw new IOException("JSON parser error, " + ex.getMessage(), ex);
}
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-httpfs
/** Convert xAttr names json to names list */
private List<String> createXAttrNames(String xattrNamesStr) throws IOException {
JSONParser parser = new JSONParser();
JSONArray jsonArray;
try {
jsonArray = (JSONArray)parser.parse(xattrNamesStr);
List<String> names = Lists.newArrayListWithCapacity(jsonArray.size());
for (Object name : jsonArray) {
names.add((String) name);
}
return names;
} catch (ParseException e) {
throw new IOException("JSON parser error, " + e.getMessage(), e);
}
}
代码示例来源:origin: HearthStats/HearthStats.net-Uploader
Object read() {
try (Reader inputReader = new InputStreamReader(connection.getInputStream(), "UTF-8")) {
JSONParser parser = new JSONParser();
return parser.parse(inputReader);
} catch (ParseException e) {
throw new UpdaterException("Unable to parse JSON due to exception " + e.getMessage(), e);
} catch (UnsupportedEncodingException e) {
throw new UpdaterException("Unable to parse JSON because UTF-8 encoding is unsupported, this should not be possible!", e);
} catch (IOException e) {
throw new UpdaterException("Unable to read data from URL " + apiUrl.toString() + " due to exception " + e.getMessage(), e);
}
}
代码示例来源:origin: fujitsu-pio/io
/**
* This method is used to the response body in JSON format.
* @return JSONObject
* @throws DaoException Exception thrown
*/
public JSONObject bodyAsJson() throws DaoException {
String res = bodyAsString();
try {
return (JSONObject) new JSONParser().parse(res);
} catch (ParseException e) {
throw DaoException.create("parse exception: " + e.getMessage(), 0);
}
}
代码示例来源:origin: fujitsu-pio/io
/**
* This method returns the response in JSON format.
* @return JSON object
* @throws DaoException Exception thrown
*/
public final JSONObject bodyAsJson() throws DaoException {
String res = bodyAsString();
try {
return (JSONObject) new JSONParser().parse(res);
} catch (ParseException e) {
throw DaoException.create("parse exception: " + e.getMessage(), 0);
}
}
代码示例来源:origin: fujitsu-pio/io
private JSONObject parseStringToJSONObject(String body) {
JSONObject bodyJSON = null;
try {
bodyJSON = (JSONObject) new JSONParser().parse(body);
} catch (ParseException e) {
fail("parse failed. [" + e.getMessage() + "]");
}
return bodyJSON;
}
代码示例来源:origin: fujitsu-pio/io
/**
* レスポンスボディをJSONで取得.
* @return JSONオブジェクト
*/
public JSONObject bodyAsJson() {
String res = null;
res = this.bodyWriter.toString();
JSONObject jsonobject = null;
try {
jsonobject = (JSONObject) new JSONParser().parse(res);
} catch (ParseException e) {
fail(e.getMessage());
}
return jsonobject;
}
代码示例来源:origin: OpenNMS/opennms
private void handleParameters(Event event, List<Parm> parameters, JSONObject body) {
final JSONParser jsonParser = new JSONParser();
for(Parm parm : parameters) {
final String parmName = "p_" + parm.getParmName().replaceAll("\\.", "_");
// Some parameter values are of type json and should be decoded properly.
// See HZN-1272
if ("json".equalsIgnoreCase(parm.getValue().getType())) {
try {
JSONObject tmpJson = (JSONObject) jsonParser.parse(parm.getValue().getContent());
body.put(parmName, tmpJson);
} catch (ParseException ex) {
LOG.error("Cannot parse parameter content '{}' of parameter '{}' from eventid {} to json: {}",
parm.getValue().getContent(), parm.getParmName(), event.getDbid(), ex.getMessage(), ex);
// To not lose the data, just use as is
body.put(parmName, parm.getValue().getContent());
}
} else {
body.put(parmName, parm.getValue().getContent());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!