本文整理匯總了Java中org.codehaus.jettison.json.JSONArray.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONArray.getString方法的具體用法?Java JSONArray.getString怎麽用?Java JSONArray.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.codehaus.jettison.json.JSONArray
的用法示例。
在下文中一共展示了JSONArray.getString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTsImports
import org.codehaus.jettison.json.JSONArray; //導入方法依賴的package包/類
protected Map<String, List<String>> getTsImports(Key key) {
try {
Map<String, List<String>> map = new HashMap<String, List<String>>();
JSONArray ar = jsonConfig.getJSONArray(key.name());
for (int i=0; i<ar.length(); i++) {
Object ob = ar.get(i);
if (ob instanceof JSONObject) {
JSONObject jsonImport = (JSONObject)ob;
String from = jsonImport.getString("from");
if (!from.isEmpty()) {
List<String> list = map.get(from);
if (list == null) {
list = new ArrayList<String>();
}
JSONArray arc = jsonImport.getJSONArray("components");
for (int j=0; j<arc.length(); j++) {
String s = arc.getString(j);
if (!s.isEmpty()) {
list.add(s);
}
}
map.put(from, list);
}
}
}
return map;
} catch (JSONException e) {
return new HashMap<String, List<String>>();
}
}
示例2: getNgImports
import org.codehaus.jettison.json.JSONArray; //導入方法依賴的package包/類
protected Set<String> getNgImports(Key key) {
try {
Set<String> set = new HashSet<String>();
JSONArray ar = jsonConfig.getJSONArray(key.name());
for (int i=0; i<ar.length(); i++) {
String s = ar.getString(i);
if (!s.isEmpty()) {
set.add(s);
}
}
return set;
} catch (JSONException e) {
return new HashSet<String>();
}
}
示例3: verifyNodeAppInfo
import org.codehaus.jettison.json.JSONArray; //導入方法依賴的package包/類
public void verifyNodeAppInfo(JSONObject info, Application app,
HashMap<String, String> hash) throws JSONException, Exception {
assertEquals("incorrect number of elements", 4, info.length());
verifyNodeAppInfoGeneric(app, info.getString("id"),
info.getString("state"), info.getString("user"));
JSONArray containerids = info.getJSONArray("containerids");
for (int i = 0; i < containerids.length(); i++) {
String id = containerids.getString(i);
assertEquals("extra containerid: " + id, id, hash.remove(id));
}
assertTrue("missing containerids", hash.isEmpty());
}
示例4: loadJsonInfo
import org.codehaus.jettison.json.JSONArray; //導入方法依賴的package包/類
private void loadJsonInfo(ConcurrentMap<String, Set<String>> infoMap, String targetInfo)
throws IOException, JSONException {
synchronized (infoMap) {
if (!infoMap.isEmpty()) {
return;
}
JSONArray buildInfo = new JSONArray(
"[" + simpleCompsBuildInfo.join(",") + "," +
extCompsBuildInfo.join(",") + "]");
for (int i = 0; i < buildInfo.length(); ++i) {
JSONObject compJson = buildInfo.getJSONObject(i);
JSONArray infoArray = null;
String type = compJson.getString("type");
try {
infoArray = compJson.getJSONArray(targetInfo);
} catch (JSONException e) {
// Older compiled extensions will not have a broadcastReceiver
// defined. Rather then require them all to be recompiled, we
// treat the missing attribute as empty.
if (e.getMessage().contains("broadcastReceiver")) {
LOG.log(Level.INFO, "Component \"" + type + "\" does not have a broadcast receiver.");
continue;
} else {
throw e;
}
}
if (!simpleCompTypes.contains(type) && !extCompTypes.contains(type)) {
continue;
}
Set<String> infoSet = Sets.newHashSet();
for (int j = 0; j < infoArray.length(); ++j) {
String info = infoArray.getString(j);
infoSet.add(info);
}
if (!infoSet.isEmpty()) {
infoMap.put(type, infoSet);
}
}
}
}