Refine search
public static JsonObject readJsonObject(String jsonString) { return Json.createReader(new StringReader(jsonString)).readObject(); }
private static JsonObject getJsonResponse(HttpURLConnection connection) throws AcmeException { JsonObject jsonResponse; try (InputStream inputStream = new BufferedInputStream(connection.getResponseCode() < 400 ? connection.getInputStream() : connection.getErrorStream())) { jsonResponse = Json.createReader(inputStream).readObject(); } catch (IOException e) { throw acme.unableToObtainJsonResponseFromAcmeServer(e); } return jsonResponse; }
public static Map<String, Set<CandidatePhrase>> readSeedWordsFromJSONString(String str){ Map<String, Set<CandidatePhrase>> seedWords = new HashMap<>(); JsonReader jsonReader = Json.createReader(new StringReader(str)); JsonObject obj = jsonReader.readObject(); jsonReader.close(); for (String o : obj.keySet()){ seedWords.put(o, new HashSet<>()); JsonArray arr = obj.getJsonArray(o); for(JsonValue v: arr) seedWords.get(o).add(CandidatePhrase.createOrGet(v.toString())); } return seedWords; }
public String doNewPhrases(String line) throws Exception { System.out.println("adding new phrases"); ConstantsAndVariables constVars = new ConstantsAndVariables(props, humanLabelClasses.keySet(), humanLabelClasses); JsonReader jsonReader = Json.createReader(new StringReader(line)); JsonObject objarr = jsonReader.readObject(); for(Map.Entry<String, JsonValue> o: objarr.entrySet()){ String label = o.getKey(); Set<CandidatePhrase> seed = new HashSet<>(); JsonArray arr = objarr.getJsonArray(o.getKey()); for(int i = 0; i < arr.size(); i++){ String seedw = arr.getString(i); System.out.println("adding " + seedw + " to seed "); seed.add(CandidatePhrase.createOrGet(seedw)); } seedWords.get(label).addAll(seed); constVars.addSeedWords(label, seed); GetPatternsFromDataMultiClass.runLabelSeedWords(Data.sents, humanLabelClasses.get(label), label, seed, constVars, false); //model.labelWords(label, labelclass, Data.sents, seed); } return "SUCCESS added new phrases"; }
private int changeAnnotation(String line, boolean remove){ int tokensNum = 0; JsonReader jsonReader = Json.createReader(new StringReader(line)); JsonObject objarr = jsonReader.readObject(); for(String label: objarr.keySet()) { JsonObject obj4label = objarr.getJsonObject(label); for(String sentid: obj4label.keySet()){ JsonArray tokenArry = obj4label.getJsonArray(sentid); for(JsonValue tokenid: tokenArry){ tokensNum ++; Data.sents.get(sentid).getTokens().get(Integer.parseInt(tokenid.toString())).set(humanLabelClasses.get(label), remove ? backgroundSymbol: label); } } } return tokensNum; }
private JsonObject extractClaims(String encodedClaims) throws RealmUnavailableException { try { Base64.Decoder urlDecoder = Base64.getUrlDecoder(); CodePointIterator decodedClaims = CodePointIterator.ofUtf8Bytes(urlDecoder.decode(encodedClaims)); return Json.createReader(decodedClaims.asUtf8().asInputStream()).readObject(); } catch (Exception cause) { throw log.tokenRealmJwtParseFailed(cause); } }
void setUpProperties(String line, boolean readFile, boolean writeOutputToFile, String additionalSeedWordsFiles) throws IOException, ClassNotFoundException { JsonReader jsonReader = Json.createReader(new StringReader(line)); JsonObject objarr = jsonReader.readObject(); jsonReader.close(); Properties props = new Properties();
JsonObject jsonObject = Json.createReader(inputStream).readObject(); String accessToken = jsonObject.getString("access_token"); return credentialType.cast(new BearerTokenCredential(accessToken));
case 200: try (InputStream in = new BufferedInputStream(conn.getInputStream()); JsonReader jsonReader = Json.createReader(in)) { final JSONObject jsonResponse = new JSONObject(jsonReader.readObject().toString()); final NpmAuditParser parser = new NpmAuditParser(); return parser.parse(jsonResponse);
private Signature createSignature(String encodedHeader, String encodedClaims) throws NoSuchAlgorithmException, SignatureException, RealmUnavailableException { byte[] headerDecoded = Base64.getUrlDecoder().decode(encodedHeader); JsonObject headers = Json.createReader(ByteIterator.ofBytes(headerDecoded).asInputStream()).readObject(); String headerAlg = resolveAlgorithm(headers); Signature signature = Signature.getInstance(headerAlg); try { PublicKey publicKey = resolvePublicKey(headers); if (publicKey == null) { log.debug("Public key could not be resolved."); return null; } signature.initVerify(publicKey); } catch (InvalidKeyException e) { e.printStackTrace(); return null; } signature.update((encodedHeader + "." + encodedClaims).getBytes()); return signature; }
try (JsonReader jsonReader = Json.createReader(FileUtils.openInputStream(dependencyFile))) { final JsonObject json = jsonReader.readObject(); final String parentName = json.getString("name", ""); final String parentVersion = json.getString("version", "");
return Json.createReader(inputStream).readObject();
conn.connect(); InputStream inputStream = conn.getInputStream(); response = Json.createReader(inputStream).readObject();
child.setEcosystem(DEPENDENCY_ECOSYSTEM); try (JsonReader jr = Json.createReader(FileUtils.openInputStream(f))) { final JsonObject childJson = jr.readObject(); gatherEvidence(childJson, child);
for (PropertyDescriptor attachment : attachments) { String s = context.getProperty(attachment).evaluateAttributeExpressions(flowFile).getValue(); JsonReader reader = Json.createReader(new StringReader(s)); JsonObject attachmentJson = reader.readObject(); jsonArrayBuiler.add(attachmentJson);
JsonObject json = Json.createReader(new StringReader(URLDecoder.decode( request.content().toString(StandardCharsets.UTF_8).split("=")[0], "UTF-8"))).readObject();
try (JsonReader jsonReader = Json.createReader(FileUtils.openInputStream(file))) { final JsonObject packageJson = jsonReader.readObject();
JsonObject root = Json.createReader( new StringReader(request.content().toString(StandardCharsets.US_ASCII))).readObject();
JsonObject root = Json.createReader( new StringReader(request.content().toString(StandardCharsets.US_ASCII))).readObject();
/** * Create a JSON object based on the given String representation of a JSON * object. * * @param jsonString * The JSON String to parse. */ public JsonWrapper(String jsonString) { // parse and pass it to the JSON constructor this(Json.createReader(new StringReader(jsonString)).readObject()); }