本文整理了Java中org.json.simple.parser.ParseException.printStackTrace()
方法的一些代码示例,展示了ParseException.printStackTrace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ParseException.printStackTrace()
方法的具体详情如下:
包路径:org.json.simple.parser.ParseException
类名称:ParseException
方法名:printStackTrace
暂无
代码示例来源:origin: ethereum/ethereumj
e.printStackTrace();
代码示例来源:origin: apache/metron
@Before
public void parseMessages() {
JSONParser parser = new JSONParser();
try {
joinedMessage = (JSONObject) parser.parse(joinedMessageString);
} catch (ParseException e) {
e.printStackTrace();
}
joinBolt = new StandAloneJoinBolt("zookeeperUrl");
joinBolt.setCuratorFramework(client);
joinBolt.setZKCache(cache);
}
代码示例来源:origin: apache/metron
private void runTest(String name, List<String> lines, String schema, String targetJson) throws Exception {
for (String inputString : lines) {
JSONObject parsed = parse(inputString).get(0);
Assert.assertNotNull(parsed);
Assert.assertNotNull(parsed.get("timestamp"));
Assert.assertTrue((long) parsed.get("timestamp") > 0);
JSONParser parser = new JSONParser();
Map<?, ?> json = null;
try {
json = (Map<?, ?>) parser.parse(parsed.toJSONString());
Assert.assertEquals(true, validateJsonData(schema, json.toString()));
} catch (ParseException e) {
e.printStackTrace();
}
// test against an explicit json example
if (!targetJson.isEmpty()) {
}
}
}
代码示例来源:origin: Exslims/MercuryTrade
public String getVersionFrom(String source) {
String version = "";
JSONParser parser = new JSONParser();
try {
JSONObject root = (JSONObject) parser.parse(source);
version = (String) root.get("version");
} catch (ParseException e) {
e.printStackTrace();
}
return version;
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
private void init(Reader reader) {
JSONParser jsonParser = new JSONParser();
try {
jsonObject = (JSONObject) jsonParser.parse(reader);
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
configs=parse(jsonObject);
}
代码示例来源:origin: usc-isi-i2/Web-Karma
public ReadEvaluatedFile(String filename) {
JSONParser parser = new JSONParser();
try {
allObjects = (JSONObject)parser.parse(new FileReader(filename));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
accuracy = (double)allObjects.get(EvaluatedJSONLabels.ACCURACY_NAME);
mrr = (double)allObjects.get(EvaluatedJSONLabels.MRR_NAME);
columns = (JSONArray)allObjects.get(EvaluatedJSONLabels.COLUMNS_NAME);
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
private static Map<String, String> parseJSON(String json) {
Map<String, String> map = new HashMap<String, String>();
if (json != null && json.length() > 2) {
try {
JSONParser parser = new JSONParser();
JSONObject obj = (JSONObject) parser.parse(json);
for (Object entry: obj.keySet()) {
String key = entry.toString();
String value = obj.get(entry).toString();
map.put(key, value);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return map;
}
代码示例来源:origin: bitquest/bitquest
public void updateLootPoolCache() {
System.out.println("[loot_cache]");
boss_already_spawned=false;
try {
Long balance=wallet.getBalance(0);
System.out.println("[loot_cache] "+balance);
if(balance>(LAND_PRICE+MINER_FEE)*2) {
REDIS.set("loot_cache",balance.toString());
}
} catch (IOException e) {
e.printStackTrace();
REDIS.del("loot_cache");
System.out.println("[loot_cache] FAIL");
} catch (org.json.simple.parser.ParseException e) {
e.printStackTrace();
REDIS.del("loot_cache");
System.out.println("[loot_cache] FAIL");
}
}
static Long witherReward() {
代码示例来源:origin: secdec/attack-surface-detector-burp
private String getBurpConfigAsString()
{
try
{
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(new FileReader(BurpPropertiesManager.getBurpPropertiesManager().getConfigFile()));
return jsonObject.toJSONString();
}
catch (ParseException e)
{
e.printStackTrace();
} catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
return "";
}
代码示例来源:origin: opencast/opencast
/**
* Get a {@link Policy} from JSON data.
*
* @param policyJson
* The {@link String} representation of the json.
* @return A new {@link Policy} object populated from the JSON.
*/
public static Policy fromJson(String policyJson) {
JSONObject jsonPolicy = null;
JSONParser jsonParser = new JSONParser();
try {
jsonPolicy = (JSONObject) jsonParser.parse(policyJson);
} catch (ParseException e) {
e.printStackTrace();
}
JSONObject statement = (JSONObject) jsonPolicy.get(STATEMENT_KEY);
String resource = statement.get(RESOURCE_KEY).toString();
JSONObject condition = (JSONObject) statement.get(CONDITION_KEY);
final String lessThanString = condition.get(DATE_LESS_THAN_KEY).toString();
final DateTime dateLessThan = new DateTime(Long.parseLong(lessThanString), DateTimeZone.UTC);
final DateTime dateGreaterThan;
Object greaterThanString = condition.get(DATE_GREATER_THAN_KEY);
if (greaterThanString != null) {
dateGreaterThan = new DateTime(Long.parseLong(greaterThanString.toString()), DateTimeZone.UTC);
} else {
dateGreaterThan = null;
}
return Policy.mkPolicyValidFromWithIP(resource, dateLessThan, dateGreaterThan,
(String) condition.get(IP_ADDRESS_KEY));
}
代码示例来源:origin: OpenSOC/opensoc-streaming
@SuppressWarnings({ "rawtypes", "deprecation" })
protected Map getThreatObject(String key) {
LOGGER.debug("=======Pinging HBase For:" + key);
Get get = new Get(Bytes.toBytes(key));
Result rs;
Map output = new HashMap();
try {
rs = table.get(get);
if (!rs.isEmpty()) {
byte[] source_family = Bytes.toBytes("source");
JSONParser parser = new JSONParser();
Map<byte[], byte[]> sourceFamilyMap = rs.getFamilyMap(source_family);
for (Map.Entry<byte[], byte[]> entry : sourceFamilyMap.entrySet()) {
String k = Bytes.toString(entry.getKey());
LOGGER.debug("=======Found intel from source: " + k);
output.put(k,parser.parse(Bytes.toString(entry.getValue())));
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return output;
}
代码示例来源:origin: org.talend.components/components-salesforce
private String getSOAPEndpoint(SalesforceOAuthAccessTokenResponse token, String version) {
String endpointURL = null;
BufferedReader reader = null;
try {
URLConnection idConn = new URL(token.getID()).openConnection();
idConn.setRequestProperty("Authorization", token.getTokenType() + " " + token.getAccessToken());
reader = new BufferedReader(new InputStreamReader(idConn.getInputStream()));
JSONParser jsonParser = new JSONParser();
JSONObject json = (JSONObject) jsonParser.parse(reader);
JSONObject urls = (JSONObject) json.get("urls");
endpointURL = urls.get("partner").toString().replace("{version}", version);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ignore) {
}
}
}
return endpointURL;
}
代码示例来源:origin: OpenSOC/opensoc-streaming
} catch (ParseException e) {
e.printStackTrace();
代码示例来源:origin: dice-group/NLIWOD
@Override
public void processQALDResp(HttpResponse response, IQuestion question) throws JsonParseException, JsonMappingException, UnsupportedOperationException, IOException {
ResponseToStringParser responseparser = new ResponseToStringParser();
JSONParser parser = new JSONParser();
String responseString = responseparser.responseToString(response);
JSONArray answerjson = null;
try {
answerjson = (JSONArray) parser.parse(responseString);
} catch (ParseException e) {
e.printStackTrace();
return;
}
HashSet<String> resultSet = new HashSet<String>();
for(int i = 0; i<answerjson.size(); i++) {
resultSet.add("https://www.wikidata.org/wiki/" + (String) answerjson.get(i));
}
//ony returns wikidata ids, nothing else
question.setGoldenAnswers(resultSet);
}
}
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.gateway
public Token getAccessToken(String consumerKey, String consumerSecret, String encodedSamlAssertion, String tokenEndPoint) {
try {
String applicationToken = consumerKey + ":" + consumerSecret;
applicationToken = "Basic " + Base64Utils.encode(applicationToken.getBytes()).trim();
String payload = "grant_type=urn:ietf:params:oauth:grant-type:saml2-bearer&assertion=" + encodedSamlAssertion;
// String payload = "grant_type=password&username=" + "admin" + "&password=admin";
String response = doPost(tokenEndPoint, applicationToken, payload, "application/x-www-form-urlencoded");
JSONParser parser = new JSONParser();
Object obj = null;
try {
obj = parser.parse(response);
} catch (ParseException e) {
e.printStackTrace();
}
JSONObject jsonObject = (JSONObject) obj;
Token token = new Token();
token.setAccessToken((String) jsonObject.get("access_token"));
long expiresIn = ((Long) jsonObject.get("expires_in")).intValue();
token.setExpiresIn(expiresIn);
token.setRefreshToken((String) jsonObject.get("refresh_token"));
token.setTokenType((String) jsonObject.get("token_type"));
return token;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
代码示例来源:origin: dice-group/NLIWOD
@Override
public void processQALDResp(HttpResponse response, IQuestion question) throws JsonParseException, JsonMappingException, UnsupportedOperationException, IOException {
HashSet<String> resultSet = new HashSet<String>();
ResponseToStringParser responseparser = new ResponseToStringParser();
JSONParser parser = new JSONParser();
String responseString = responseparser.responseToString(response);
JSONObject answerjson = null;
try {
answerjson = (JSONObject) parser.parse(responseString);
} catch (ParseException e) {
e.printStackTrace();
return;
}
JSONArray answers = (JSONArray) answerjson.get("answers");
for(int i = 0; i<answers.size(); i++) {
resultSet.add((String) answers.get(i));
}
question.setGoldenAnswers(resultSet);
question.setSparqlQuery((String) answerjson.get("sparql"));
}
}
代码示例来源:origin: dice-group/NLIWOD
@Override
public void processQALDResp(HttpResponse response, IQuestion question) throws JsonParseException, JsonMappingException, UnsupportedOperationException, IOException {
HashSet<String> resultSet = new HashSet<String>();
ResponseToStringParser responseparser = new ResponseToStringParser();
JSONParser parser = new JSONParser();
String responseString = responseparser.responseToString(response);
JSONObject answerjson = null;
try {
answerjson = (JSONObject) parser.parse(responseString);
} catch (ParseException e) {
e.printStackTrace();
return;
}
answerjson = (JSONObject) answerjson.get("fullDetail");
//if no answer just return
if(((JSONArray) answerjson.get("answers")).size() == 0) return;
JSONArray answers = (JSONArray) ((JSONArray) answerjson.get("answers")).get(0);
for(int i = 0; i< answers.size(); i++) {
JSONObject answer = (JSONObject) answers.get(i);
String key = (String) answer.keySet().toArray()[0];
answer = (JSONObject) answer.get(key);
resultSet.add((String) answer.get("value"));
}
question.setGoldenAnswers(resultSet);
JSONArray queries = (JSONArray) ((JSONObject) answerjson.get("sparql")).get("queries");
String query = (String) queries.get(0);
question.setSparqlQuery(query.trim());
}
}
代码示例来源:origin: renepickhardt/metalcon
/**
* access the status update loaded<br>
* (calls will cause an exception if you did not successfully load one
* before)
*
* @return status update loaded before
*/
@SuppressWarnings("unchecked")
public JSONObject getStatusUpdate() {
JSONObject statusUpdate = null;
try {
statusUpdate = (JSONObject) JSON_PARSER
.parse((String) this.nextStatusUpdateNode
.getProperty(Properties.StatusUpdate.CONTENT));
} catch (final ParseException e) {
e.printStackTrace();
}
// (create and) add user object
if (this.userJSON == null) {
final User user = new User(this.userNode);
this.userJSON = user.toActorJSON();
}
statusUpdate.put("actor", this.userJSON);
this.nextStatusUpdate();
return statusUpdate;
}
代码示例来源:origin: alrocar/POIProxy
/**
* {@inheritDoc}
*/
public ArrayList<JTSFeature> parse(String json, DescribeService service,
LocalFilter filter) {
simpleContentHandler.setJPEParseContentHandler(contentHandler);
simpleContentHandler.setJPEWriteContentHandler(writerHandler);
simpleContentHandler.setDescribeService(service);
simpleContentHandler.setLocalFilter(filter);
try {
parser.parse(json, simpleContentHandler);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
return simpleContentHandler.getResult();
}
代码示例来源:origin: dice-group/NLIWOD
answerjson = (JSONObject) parser.parse(responseString);
} catch (ParseException e) {
e.printStackTrace();
return;
内容来源于网络,如有侵权,请联系作者删除!