本文整理了Java中org.json.simple.JSONArray.toArray()
方法的一些代码示例,展示了JSONArray.toArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.toArray()
方法的具体详情如下:
包路径:org.json.simple.JSONArray
类名称:JSONArray
方法名:toArray
暂无
代码示例来源:origin: ethereum/ethereumj
private void init(JSONArray jLogs) {
logs = new ArrayList<>();
for (Object jLog1 : jLogs) {
JSONObject jLog = (JSONObject) jLog1;
byte[] address = Hex.decode((String) jLog.get("address"));
byte[] data = Hex.decode(((String) jLog.get("data")).substring(2));
List<DataWord> topics = new ArrayList<>();
JSONArray jTopics = (JSONArray) jLog.get("topics");
for (Object t : jTopics.toArray()) {
byte[] topic = Hex.decode(((String) t));
topics.add(DataWord.of(topic));
}
LogInfo li = new LogInfo(address, topics, data);
logs.add(li);
}
}
代码示例来源:origin: gradle.plugin.org.mockito/release
private static Collection<String> extractLabels(JSONObject issue) {
Set<String> out = new HashSet<String>();
JSONArray labels = (JSONArray) issue.get("labels");
for (Object o : labels.toArray()) {
JSONObject label = (JSONObject) o;
out.add((String) label.get("name"));
}
return out;
}
代码示例来源:origin: stackoverflow.com
JSONObject resultsJSONObject = (JSONObject) JSONValue.parse(<<Fetched JSon String>>);
JSONArray dataJSon = (JSONArray) resultsJSONObject.get("data");
JSONObject[] updates = dataJSon.toArray(new JSONObject[dataJSon.size()]);
for (JSONObject update : updates) {
String message_id = (String) update.get("message_id");
Integer author_id = (Integer) update.get("author_id");
Integer createdTime = (Integer) update.get("created_time");
//Do your own processing...
//Here you can check null value or not..
}
代码示例来源:origin: quintona/storm-r
public Values coerceResponce(JSONArray array){
return new Values(array.toArray());
}
代码示例来源:origin: com.googlecode.redbox-mint/redbox-reports
public JsonObject findJsonObjectWithKey(String keyName) {
Object[] reportCriteriaOptions = reportCriteriaOptionsJson.getArray(
"results").toArray();
for (Object object : reportCriteriaOptions) {
JsonObject jsonObject = (JsonObject) object;
if (keyName.equals(jsonObject.get("key"))) {
return jsonObject;
}
}
return null;
}
代码示例来源:origin: dice-group/NLIWOD
for (Object res : resources.toArray()) {
JSONObject next = (JSONObject) res;
String namedEntity = (String) next.get("namedEntity");
代码示例来源:origin: opencast/opencast
@POST
@Path("removejobs")
@RestQuery(name = "removejobs", description = "Removes all given jobs and their child jobs", returnDescription = "No data is returned, just the HTTP status code", restParameters = { @RestParameter(name = "jobIds", isRequired = true, description = "The IDs of the jobs to delete", type = Type.TEXT), }, reponses = {
@RestResponse(responseCode = SC_NO_CONTENT, description = "Jobs successfully removed"),
@RestResponse(responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR, description = "Error while removing jobs") })
public Response removeParentlessJobs(@FormParam("jobIds") String jobIds) throws NotFoundException {
try {
final JSONArray array = (JSONArray) JSONValue.parse(jobIds);
final List<Long> jobIdList = Arrays.asList((Long[]) array.toArray(new Long[0]));
serviceRegistry.removeJobs(jobIdList);
return Response.noContent().build();
} catch (ServiceRegistryException e) {
throw new WebApplicationException(e);
}
}
代码示例来源:origin: dice-group/NLIWOD
public Map<String, List<Entity>> getEntities(final String question) {
HashMap<String, List<Entity>> tmp = new HashMap<>();
try {
String JSONOutput = doTASK(question);
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(JSONOutput);
JSONArray resources = (JSONArray) jsonObject.get("Resources");
if (resources != null) {
ArrayList<Entity> tmpList = new ArrayList<>();
for (Object res : resources.toArray()) {
JSONObject next = (JSONObject) res;
Entity ent = new Entity();
ent.setOffset(Integer.valueOf((String) next.get("@offset")));
ent.setLabel((String) next.get("@surfaceForm"));
String uri = ((String) next.get("@URI")).replaceAll(",", "%2C");
ent.getUris().add(new ResourceImpl(uri));
for (String type : ((String) next.get("@types")).split(",")) {
ent.getPosTypesAndCategories().add(new ResourceImpl(type));
}
tmpList.add(ent);
}
tmp.put("en", tmpList);
}
} catch (IOException | ParseException e) {
log.error("Could not call Spotlight for NER/NED", e);
}
return tmp;
}
代码示例来源:origin: dice-group/NLIWOD
@Override
public Map<String, List<Entity>> getEntities(final String question) {
HashMap<String, List<Entity>> tmp = new HashMap<>();
try {
String foxJSONOutput = doTASK(question);
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(foxJSONOutput);
JSONArray resources = (JSONArray) jsonObject.get("Resources");
if (resources != null) {
ArrayList<Entity> tmpList = new ArrayList<>();
for (Object res : resources.toArray()) {
JSONObject next = (JSONObject) res;
Entity ent = new Entity();
ent.setOffset(Integer.valueOf((String) next.get("@offset")));
ent.setLabel((String) next.get("@surfaceForm"));
String uri = ((String) next.get("@URI")).replaceAll(",", "%2C");
ent.getUris().add(new ResourceImpl(uri));
for (String type : ((String) next.get("@types")).split(",")) {
ent.getPosTypesAndCategories().add(new ResourceImpl(type));
}
tmpList.add(ent);
}
tmp.put("en", tmpList);
}
} catch (IOException | ParseException e) {
log.error("Could not call Spotlight for NER/NED", e);
}
return tmp;
}
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.gateway
if (responseString != null && !responseString.isEmpty()) {
JSONArray jsonArray = (JSONArray) new JSONParser().parse(responseString);
return (String[]) jsonArray.toArray(new String[jsonArray.size()]);
代码示例来源:origin: com.googlecode.the-fascinator.plugins/plugin-roles-internal
public void setConfig(JsonSimpleConfig config) throws IOException {
// Get the basics
file_path = config.getString(null, "roles", "internal", "path");
loadRoles();
JSONArray roleJsonArray = (JSONArray)config.getObject("roles", "internal").get("defaultRoles");
if(roleJsonArray != null) {
defaultRoles = Arrays.copyOf(roleJsonArray.toArray(), roleJsonArray.size(), String[].class);
}
}
代码示例来源:origin: com.adobe.ride/ride-model-util
/**
* Method to retrieve one of the definitions from the anyOf value from a schema node definition
*
* @param propertyObject the node from a schema which has a type of 'AnyOf'
* @return Object random member definition of the one of the objects in the AnyOf json schema
* field.
*/
private Object getOneOfAnyOf(JSONObject propertyObject) {
Object[] array = ((JSONArray) propertyObject.get("anyOf")).toArray();
Validate.isTrue(array.length > 0);
JSONObject nodeDef = (JSONObject) array[DataGenerator.generateRandomInt(0, array.length - 1)];
Object object = null;;
try {
object = generateNodeValue(null, null, nodeDef);
} catch (ModelSearchException e) {
e.printStackTrace();
}
return object;
}
代码示例来源:origin: dice-group/NLIWOD
for (Object res : resources.toArray()) {
JSONObject next = (JSONObject) res;
Entity ent = new Entity();
代码示例来源:origin: fujitsu-pio/io
@SuppressWarnings("unchecked")
private JSONArray skipNullResults(JSONArray source, String propertyName) {
JSONArray result = new JSONArray();
for (Object item : source.toArray()) {
if (((JSONObject) item).get(propertyName) == null) {
continue;
}
result.add(item);
}
return result;
}
}
代码示例来源:origin: fujitsu-pio/io
@SuppressWarnings("unchecked")
private JSONArray skipNullResults(JSONArray source, String propertyName) {
JSONArray result = new JSONArray();
for (Object item : source.toArray()) {
if (((JSONObject) item).get(propertyName) == null) {
continue;
}
result.add(item);
}
return result;
}
}
代码示例来源:origin: activequant/aq2o
} else {
JSONArray js = (JSONArray) val;
map.put(key, js.toArray());
if (js.size() > 0) {
Object o = js.get(0);
代码示例来源:origin: com.adobe.ride/ride-model-util
logger.log(Level.SEVERE, "A Parse exception was thrown", e);
Object[] enumArray = enums.toArray();
String enumValue =
enumArray[DataGenerator.generateRandomInt(0, enumArray.length - 1)].toString();
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl
updatePolicyGroups(webAppId, policyGroupIdList.toArray(), connection);
updateJavaPolicies(webAppId, javaPolicyIdList.toArray(), connection);
代码示例来源:origin: fujitsu-pio/io
source.size()));
Object[] expectedArray = source.toArray();
Object[] targetArray = toBeCompared.toArray();
Arrays.sort(expectedArray);
Arrays.sort(targetArray);
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl
if (app.getPolicyPartials() != null && !app.getPolicyPartials().isEmpty()) {
JSONArray policyPartialIdList = (JSONArray) JSONValue.parse(app.getPolicyPartials());
saveApplicationPolicyPartialsMappings(connection, webAppId, policyPartialIdList.toArray());
saveApplicationPolicyGroupsMappings(connection, webAppId, policyGroupIdList.toArray());
saveJavaPolicyMappings(connection, webAppId, javaPolicyIdList.toArray());
内容来源于网络,如有侵权,请联系作者删除!