当前位置: 首页>>代码示例>>Java>>正文


Java JSONArray类代码示例

本文整理汇总了Java中org.json.simple.JSONArray的典型用法代码示例。如果您正苦于以下问题:Java JSONArray类的具体用法?Java JSONArray怎么用?Java JSONArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JSONArray类属于org.json.simple包,在下文中一共展示了JSONArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillAnnotations

import org.json.simple.JSONArray; //导入依赖的package包/类
private void fillAnnotations(@SuppressWarnings("unused") Logger logger, Section sec, JSONObject json, Map<String,Element> eltMap) {
	JSONArray catanns = (JSONArray) json.get("catanns");
	if (catanns == null) {
		return;
	}
	Layer annotations = sec.ensureLayer(annotationsLayerName);
	for (Object o : catanns) {
		JSONObject ca = (JSONObject) o;
		String id = (String) ca.get("id");
		JSONObject span = (JSONObject) ca.get("span");
		int begin = (int) (long) span.get("begin");
		int end = (int) (long) span.get("end");
		String category = (String) ca.get("category");
		Layer layer = sec.ensureLayer(category);
		Annotation a = new Annotation(this, layer, begin, end);
		annotations.add(a);
		a.addFeature("id", id);
		a.addFeature("category", category);
		eltMap.put(id, a);
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:22,代码来源:GeniaJSONReader.java

示例2: aclStatusToJSON

import org.json.simple.JSONArray; //导入依赖的package包/类
/** Converts an <code>AclStatus</code> object into a JSON object.
 *
 * @param aclStatus AclStatus object
 *
 * @return The JSON representation of the ACLs for the file
 */
@SuppressWarnings({"unchecked"})
private static Map<String,Object> aclStatusToJSON(AclStatus aclStatus) {
  Map<String,Object> json = new LinkedHashMap<String,Object>();
  Map<String,Object> inner = new LinkedHashMap<String,Object>();
  JSONArray entriesArray = new JSONArray();
  inner.put(HttpFSFileSystem.OWNER_JSON, aclStatus.getOwner());
  inner.put(HttpFSFileSystem.GROUP_JSON, aclStatus.getGroup());
  inner.put(HttpFSFileSystem.ACL_STICKY_BIT_JSON, aclStatus.isStickyBit());
  for ( AclEntry e : aclStatus.getEntries() ) {
    entriesArray.add(e.toString());
  }
  inner.put(HttpFSFileSystem.ACL_ENTRIES_JSON, entriesArray);
  json.put(HttpFSFileSystem.ACL_STATUS_JSON, inner);
  return json;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:FSOperations.java

示例3: createHar

import org.json.simple.JSONArray; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void createHar(String pt, String rt) {
    Har<String, Log> har = new Har<>();
    Page p = new Page(pt, har.pages());
    har.addPage(p);
    for (Object res : (JSONArray) JSONValue.parse(rt)) {
        JSONObject jse = (JSONObject) res;
        if (jse.size() > 14) {
            Entry e = new Entry(jse.toJSONString(), p);
            har.addEntry(e);
        }
    }
    har.addRaw(pt, rt);
    Control.ReportManager.addHar(har, (TestCaseReport) Report,
            escapeName(Data));
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:Performance.java

示例4: parseRestApiEntries

import org.json.simple.JSONArray; //导入依赖的package包/类
/**
 * Parses the alfresco REST API response for a collection of entries.
 * Basically, it looks for the {@code list} JSON object, then it uses
 * {@literal Jackson} to convert the list's entries to their corresponding
 * POJOs based on the given {@code clazz}.
 * 
 * @param jsonObject the {@code JSONObject} derived from the response
 * @param clazz the class which represents the JSON payload
 * @return list of POJOs of the given {@code clazz} type
 * @throws Exception
 */
public static <T> List<T> parseRestApiEntries(JSONObject jsonObject, Class<T> clazz) throws Exception
{
    assertNotNull(jsonObject);
    assertNotNull(clazz);

    List<T> models = new ArrayList<>();

    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    assertNotNull(jsonList);

    JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
    assertNotNull(jsonEntries);

    for (int i = 0; i < jsonEntries.size(); i++)
    {
        JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
        T pojoModel = parseRestApiEntry(jsonEntry, clazz);
        models.add(pojoModel);
    }

    return models;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:34,代码来源:RestApiUtil.java

示例5: toMap

import org.json.simple.JSONArray; //导入依赖的package包/类
public static Map<String, Object> toMap(JSONObject jsonObject) throws JSONException {
    Map<String, Object> map = new HashMap<>();

    for (Object key : jsonObject.keySet()) {
        Object value = jsonObject.get(key);

        if (value instanceof JSONObject) {
            value = MapUtil.toMap((JSONObject) value);
        }
        if (value instanceof JSONArray) {
            value = ArrayUtil.toArray((JSONArray) value);
        }

        map.put(String.valueOf(key), value);
    }

    return map;
}
 
开发者ID:CanalTP,项目名称:RNNavitiaSDK,代码行数:19,代码来源:MapUtil.java

示例6: getChartData

import org.json.simple.JSONArray; //导入依赖的package包/类
@Override
protected JSONObject getChartData() {
    JSONObject data = new JSONObject();
    JSONObject values = new JSONObject();
    HashMap<String, Integer> map = getValues(new HashMap<String, Integer>());
    if (map == null || map.isEmpty()) {
        // Null = skip the chart
        return null;
    }
    for (Map.Entry<String, Integer> entry : map.entrySet()) {
        JSONArray categoryValues = new JSONArray();
        categoryValues.add(entry.getValue());
        values.put(entry.getKey(), categoryValues);
    }
    data.put("values", values);
    return data;
}
 
开发者ID:Ladinn,项目名称:JavaShell,代码行数:18,代码来源:Metrics.java

示例7: allEntityTypeDelete

import org.json.simple.JSONArray; //导入依赖的package包/类
/**
 * すべてのEntityTypeのDELETE.
  * @param path
 *            コレクションパス
 * @param cellPath
 *            セル名
 * @return レスポンス
 */
public static TResponse allEntityTypeDelete(final String path, final String cellPath) {

    // EntityType全件取得
    TResponse res = Http.request("box/entitySet-query.txt").with("cellPath", cellPath).with("odataSvcPath", path)
            .with("token", AbstractCase.MASTER_TOKEN_NAME).with("accept", MediaType.APPLICATION_JSON).returns();

    JSONObject d = (JSONObject) res.bodyAsJson().get("d");
    if (d != null) {
        JSONArray results = (JSONArray) d.get("results");
        for (Object result : results) {
            JSONObject account = (JSONObject) result;
            String entityName = (String) account.get("Name");
            entityTypeDelete(path, entityName, cellPath, TEST_BOX1);
        }
    }
    return res;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:26,代码来源:Setup.java

示例8: receiveGET

import org.json.simple.JSONArray; //导入依赖的package包/类
/**
 * Implemented receiveGET from Interface interfaceAPI (see for more details)
 *
 * @throws IOException    IO Error
 * @throws ParseException Parse Error
 */
public void receiveGET () throws IOException, ParseException {
    JSONArray JSONArray = readResponseJSON(API_IDENTIFIER, EntityUtils.toString(httpEntity, "UTF-8"), "annotations");

    if (JSONArray != null) {
        for (Object aJSONArray : JSONArray) {

            JSONObject object = (JSONObject) aJSONArray;
            ResponseEntry entity = new ResponseEntry();

            String s = (String) object.get("spot");
            s = addEntity(s);

            // Add Entity only if it is new and has not been added before
            if (s != null) {
                entity.setEntry(s);
                entity.setConfidence((Double) object.get("confidence"));
                foundEntryList.add(entity);
            }
        }

        // Sort the Array List Entities from A to Z
        Collections.sort(foundEntryList, new SortResponseEntity());
    }
}
 
开发者ID:CCWI,项目名称:keywordEntityApiRankService,代码行数:31,代码来源:DandelionAPI.java

示例9: getM5

import org.json.simple.JSONArray; //导入依赖的package包/类
public long getM5(String json) throws ParseException {
    long m5 = 0;
    if (json != null) {
        JSONParser parser = new JSONParser();
        JSONObject battleNetCharacter = (JSONObject) parser.parse(json);
        JSONObject achivements = (JSONObject) battleNetCharacter.get("achievements");
        JSONArray criteriaObject = (JSONArray) achivements.get("criteria");
        int criteriaNumber = -1;
        for (int i = 0; i < criteriaObject.size(); i++) {
            if ((long)criteriaObject.get(i) == 33097) {
                criteriaNumber = i;
            }
        }

        if (criteriaNumber != -1) {
            m5 = (long) ((JSONArray)achivements.get("criteriaQuantity")).get(criteriaNumber);
            if (m5 >= 1) {
                m5 += 1;
            }
        }
    }
    return m5;
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:24,代码来源:IlvlCommand.java

示例10: getPluginData

import org.json.simple.JSONArray; //导入依赖的package包/类
/**
 * Gets the plugin specific data.
 * This method is called using Reflection.
 *
 * @return The plugin specific data.
 */
public JSONObject getPluginData() {
    JSONObject data = new JSONObject();

    String pluginName = plugin.getDescription().getName();
    String pluginVersion = plugin.getDescription().getVersion();

    data.put("pluginName", pluginName); // Append the name of the plugin
    data.put("pluginVersion", pluginVersion); // Append the version of the plugin
    JSONArray customCharts = new JSONArray();
    for (CustomChart customChart : charts) {
        // Add the data of the custom charts
        JSONObject chart = customChart.getRequestJsonObject();
        if (chart == null) { // If the chart is null, we skip it
            continue;
        }
        customCharts.add(chart);
    }
    data.put("customCharts", customCharts);

    return data;
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:28,代码来源:Metrics.java

示例11: getHars

import org.json.simple.JSONArray; //导入依赖的package包/类
static Object getHars(File p, String page) {
    JSONArray dataset = new JSONArray();
    try {
        File[] list = p.listFiles(new FileFilter() {
            @Override
            public boolean accept(File file) {
                return file.getName().endsWith(".har");
            }
        });
        if (list != null) {
            for (File f : list) {
                JSONObject har = new JSONObject();
                har.put("name", f.getName().substring(0, f.getName().length() - 4));
                har.put("loc", f.getName());
                har.put("pageName", page);
                dataset.add(har);
            }
        }
    } catch (Exception ex) {
        LOG.log(Level.WARNING, "Error while reading report history", ex);
    }

    return dataset;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:25,代码来源:HarCompareHandler.java

示例12: getPluginData

import org.json.simple.JSONArray; //导入依赖的package包/类
/**
    * Gets the plugin specific data.
    * This method is called using Reflection.
    *
    * @return The plugin specific data.
    */
   @SuppressWarnings("unchecked")
public JSONObject getPluginData() {
       JSONObject data = new JSONObject();

       String pluginName = plugin.getDescription().getName();
       String pluginVersion = plugin.getDescription().getVersion();

       data.put("pluginName", pluginName); // Append the name of the plugin
       data.put("pluginVersion", pluginVersion); // Append the version of the plugin
       JSONArray customCharts = new JSONArray();
       for (CustomChart customChart : charts) {
           // Add the data of the custom charts
           JSONObject chart = customChart.getRequestJsonObject();
           if (chart == null) { // If the chart is null, we skip it
               continue;
           }
           customCharts.add(chart);
       }
       data.put("customCharts", customCharts);

       return data;
   }
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:29,代码来源:Metrics.java

示例13: loadSupportedProperties

import org.json.simple.JSONArray; //导入依赖的package包/类
private Map<String,PropertyInfo> loadSupportedProperties() {
    Map<String,PropertyInfo> map = new HashMap<>();
    try (InputStream stream = getClass().getResourceAsStream("Longhands.properties"); ) { // NOI18N
        Properties properties = new Properties();
        properties.load(stream);
        for(String name: properties.stringPropertyNames()) {
            StringTokenizer tokenizer = new StringTokenizer(properties.getProperty(name), ","); // NOI18N
            JSONArray longhands = new JSONArray();
            while (tokenizer.hasMoreTokens()) {
                String longhand = tokenizer.nextToken();
                longhands.add(longhand);
            }
            JSONObject json = new JSONObject();
            json.put("name", name); // NOI18N
            json.put("longhands", longhands); // NOI18N
            map.put(name, new PropertyInfo(json));
        }
    } catch (IOException ioex) {
        Logger.getLogger(CSS.class.getName()).log(Level.INFO, null, ioex);
    }
    return map;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CSS.java

示例14: normalizeStackTrace

import org.json.simple.JSONArray; //导入依赖的package包/类
private JSONArray normalizeStackTrace(JSONArray callStack) {
    JSONArray res = new JSONArray();
    for (Object o : callStack) {
        JSONObject cf = (JSONObject)o;
        JSONObject ncf = new JSONObject();
        ncf.put("lineNumber", ((JSONObject)cf.get("location")).get("lineNumber"));
        ncf.put("columnNumber", ((JSONObject)cf.get("location")).get("columnNumber"));
        ncf.put("function", cf.get("functionName"));
        Script sc = getScript((String)((JSONObject)(cf.get("location"))).get("scriptId"));
        if (sc == null) {
            continue;
        }
        ncf.put("script", sc.getURL());
        res.add(ncf);
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Debugger.java

示例15: getChartData

import org.json.simple.JSONArray; //导入依赖的package包/类
@Override
protected JSONObject getChartData() throws Exception {
    JSONObject data = new JSONObject();
    JSONObject values = new JSONObject();
    Map<String, Integer> map = callable.call();
    if (map == null || map.isEmpty()) {
        // Null = skip the chart
        return null;
    }
    for (Map.Entry<String, Integer> entry : map.entrySet()) {
        JSONArray categoryValues = new JSONArray();
        categoryValues.add(entry.getValue());
        values.put(entry.getKey(), categoryValues);
    }
    data.put("values", values);
    return data;
}
 
开发者ID:WheezyGold7931,项目名称:skript-hack,代码行数:18,代码来源:Metrics.java


注:本文中的org.json.simple.JSONArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。