ObjectScope(JsonObject object) { this.it = object.entrySet().iterator(); }
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 void decodePosition(JsonObject object, Position position) { for (Map.Entry<String, JsonValue> param : object.entrySet()) { String paramName = param.getKey(); JsonValue paramValue = param.getValue(); int index = -1; if (paramName.contains("#")) { String[] parts = paramName.split("#"); paramName = parts[0]; index = Integer.parseInt(parts[1]); } if (!decodeParam(paramName, index, paramValue, position)) { decodeUnknownParam(param.getKey(), param.getValue(), position); } } if (position.getLatitude() == 0 && position.getLongitude() == 0) { getLastLocation(position, position.getDeviceTime()); } }
@Override public void writeObject(JsonObject object) { if (writeDone) { throw new IllegalStateException(JsonMessages.WRITER_WRITE_ALREADY_CALLED()); } writeDone = true; generator.writeStartObject(); for(Map.Entry<String, JsonValue> e : object.entrySet()) { generator.write(e.getKey(), e.getValue()); } generator.writeEnd(); // Flush the generator's buffered contents. This won't work for byte // streams as intermediary OutputStreamWriter buffers. generator.flushBuffer(); // Flush buffered contents but not the byte stream. generator.flush() // does OutputStreamWriter#flushBuffer (package private) and underlying // byte stream#flush(). Here underlying stream's flush() is no-op. if (os != null) { generator.flush(); } }
} else if (value instanceof JsonObject) { final JsonObject jsonObject = (JsonObject) value; for (final Map.Entry<String, JsonValue> entry : jsonObject.entrySet()) { final String property = entry.getKey(); final JsonValue subValue = entry.getValue();
/** * Returns a {@link Attributes} instance based on the given {@link JsonObject}. * * @param claims a json object with the claims to extract * @return an {@link Attributes} instance with attributes from the given json object */ public static Attributes toAttributes(JsonObject claims) { return claims.entrySet().stream().reduce(new MapAttributes(), (mapAttributes, entry) -> { String claimName = entry.getKey(); JsonValue claimValue = entry.getValue(); if (JsonValue.ValueType.ARRAY.equals(claimValue.getValueType())) { JsonArray jsonArray = claims.getJsonArray(claimName); jsonArray.forEach(arrayValue -> mapAttributes.addLast(claimName, asString(arrayValue))); } else { mapAttributes.addLast(claimName, asString(claimValue)); } return mapAttributes; }, (mapAttributes, mapAttributes2) -> mapAttributes); }
/** * Processes a part of package.json (as defined by JsonObject) and update * the specified dependency with relevant info. * * @param engine the dependency-check engine * @param dependency the Dependency to update * @param jsonObject the jsonObject to parse * @param depType the dependency type */ protected void processPackage(Engine engine, Dependency dependency, JsonObject jsonObject, String depType) { for (int i = 0; i < jsonObject.size(); i++) { for (Map.Entry<String, JsonValue> entry : jsonObject.entrySet()) { final String name = entry.getKey(); String version = ""; if (entry.getValue() != null && entry.getValue().getValueType() == JsonValue.ValueType.STRING) { version = ((JsonString) entry.getValue()).getString(); } final Dependency existing = findDependency(engine, name, version); if (existing == null) { final Dependency nodeModule = createDependency(dependency, name, version, depType); engine.addDependency(nodeModule); } else { existing.addProjectReference(dependency.getName() + ": " + depType); } } } }
if (json.containsKey("dependencies")) { final JsonObject deps = json.getJsonObject("dependencies"); for (Map.Entry<String, JsonValue> entry : deps.entrySet()) { final JsonObject jo = (JsonObject) entry.getValue(); final String name = entry.getKey();
JsonObject object = (JsonObject)value; writeStartObject(); for(Map.Entry<String, JsonValue> member: object.entrySet()) { write(member.getKey(), member.getValue());
JsonObject object = (JsonObject)value; writeStartObject(name); for(Map.Entry<String, JsonValue> member: object.entrySet()) { write(member.getKey(), member.getValue());
ObjectScope(JsonObject object) { this.it = object.entrySet().iterator(); }
private static Properties extractProperties(JsonObject json, String fieldName) { Properties props = new Properties(); // Extract any other grpc options JsonObject options = getJsonObject(json, fieldName); if (options != null) { for (Entry<String, JsonValue> entry : options.entrySet()) { String key = entry.getKey(); JsonValue value = entry.getValue(); props.setProperty(key, getJsonValue(value)); } } return props; }
private Map<String, JsonObject> findCertificateAuthorities() throws NetworkConfigurationException { Map<String, JsonObject> ret = new HashMap<>(); JsonObject jsonCertificateAuthorities = getJsonObject(jsonConfig, "certificateAuthorities"); if (null != jsonCertificateAuthorities) { for (Entry<String, JsonValue> entry : jsonCertificateAuthorities.entrySet()) { String name = entry.getKey(); JsonObject jsonCA = getJsonValueAsObject(entry.getValue()); if (jsonCA == null) { throw new NetworkConfigurationException(format("Error loading config. Invalid CA entry: %s", name)); } ret.put(name, jsonCA); } } return ret; }
private void createAllOrganizations(Map<String, JsonObject> foundCertificateAuthorities) throws NetworkConfigurationException { // Sanity check if (organizations != null) { throw new NetworkConfigurationException("INTERNAL ERROR: organizations has already been initialized!"); } organizations = new HashMap<>(); // organizations is a JSON object containing a nested object for each Org JsonObject jsonOrganizations = getJsonObject(jsonConfig, "organizations"); if (jsonOrganizations != null) { for (Entry<String, JsonValue> entry : jsonOrganizations.entrySet()) { String orgName = entry.getKey(); JsonObject jsonOrg = getJsonValueAsObject(entry.getValue()); if (jsonOrg == null) { throw new NetworkConfigurationException(format("Error loading config. Invalid Organization entry: %s", orgName)); } OrgInfo org = createOrg(orgName, jsonOrg, foundCertificateAuthorities); organizations.put(orgName, org); } } }
private void createAllOrderers() throws NetworkConfigurationException { // Sanity check if (orderers != null) { throw new NetworkConfigurationException("INTERNAL ERROR: orderers has already been initialized!"); } orderers = new HashMap<>(); // orderers is a JSON object containing a nested object for each orderers JsonObject jsonOrderers = getJsonObject(jsonConfig, "orderers"); if (jsonOrderers != null) { for (Entry<String, JsonValue> entry : jsonOrderers.entrySet()) { String ordererName = entry.getKey(); JsonObject jsonOrderer = getJsonValueAsObject(entry.getValue()); if (jsonOrderer == null) { throw new NetworkConfigurationException(format("Error loading config. Invalid orderer entry: %s", ordererName)); } Node orderer = createNode(ordererName, jsonOrderer, "url"); if (orderer == null) { throw new NetworkConfigurationException(format("Error loading config. Invalid orderer entry: %s", ordererName)); } orderers.put(ordererName, orderer); } } }
for (Entry<String, JsonValue> entry : jsonPeers.entrySet()) { String peerName = entry.getKey();
@Override public void writeObject(JsonObject object) { if (writeDone) { throw new IllegalStateException(JsonMessages.WRITER_WRITE_ALREADY_CALLED()); } writeDone = true; generator.writeStartObject(); for(Map.Entry<String, JsonValue> e : object.entrySet()) { generator.write(e.getKey(), e.getValue()); } generator.writeEnd(); // Flush the generator's buffered contents. This won't work for byte // streams as intermediary OutputStreamWriter buffers. generator.flushBuffer(); // Flush buffered contents but not the byte stream. generator.flush() // does OutputStreamWriter#flushBuffer (package private) and underlying // byte stream#flush(). Here underlying stream's flush() is no-op. if (os != null) { generator.flush(); } }
throw new ChaincodeCollectionConfigurationException(format("Expected policy size of 1 but got %d", policy.size())); final String key = policy.entrySet().iterator().next().getKey();
JsonObject object = (JsonObject)value; writeStartObject(); for(Map.Entry<String, JsonValue> member: object.entrySet()) { write(member.getKey(), member.getValue());
JsonObject object = (JsonObject)value; writeStartObject(name); for(Map.Entry<String, JsonValue> member: object.entrySet()) { write(member.getKey(), member.getValue());