本文整理汇总了Java中com.eclipsesource.json.JsonArray.size方法的典型用法代码示例。如果您正苦于以下问题:Java JsonArray.size方法的具体用法?Java JsonArray.size怎么用?Java JsonArray.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.eclipsesource.json.JsonArray
的用法示例。
在下文中一共展示了JsonArray.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchesSafely
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public boolean matchesSafely(JsonArray json) {
boolean itemFound = false;
final int expectedAttributes = jsonFieldNames.size();
for (int jsonArrayIndex = 0; jsonArrayIndex < json.size();
jsonArrayIndex++) {
final JsonObject jsonHost = json.get(jsonArrayIndex).asObject();
if (jsonHost.names().size() < expectedAttributes) {
reason = "Found a virtual network with the wrong number of attributes";
return false;
}
if (checkKey != null && checkKey.test(vnetEntity, jsonHost)) {
itemFound = true;
assertThat(jsonHost, matchesVnetEntity(vnetEntity, jsonFieldNames, getValue));
}
}
if (!itemFound) {
reason = getKey.apply(vnetEntity) + " was not found";
return false;
}
return true;
}
示例2: Route
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public Route(JPTI jpti,JsonObject json){
this(jpti);
try{
agencyID=json.getInt(AGENCY_ID,-1);
number=json.getInt(NO,-1);
name=json.getString(NAME,"");
nickName=json.getString(NICKNAME,"");
description=json.getString(DESCRIPTION,"");
type=json.getInt(TYPE,2);
url=json.getString(URL,"");
color=new Color(json.getString(COLOR,"#000000"));
textColor=new Color(json.getString(TEXT_COLOR,""));
JsonArray stationArray=json.get(STATION).asArray();
for(int i=0;i<stationArray.size();i++){
stationList.add(newRouteStation(stationArray.get(i).asObject()));
}
}catch (Exception e){
}
}
示例3: fromId
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
/**
* Get strawpoll from its ID
* @param id ID to lookup
* @return Strawpoll Object
* @throws IOException Strawpoll.me is down or denied our API access
*/
public static StrawpollObject fromId(int id) throws IOException {
JsonValue jv = Util.jsonFromUrl(BASE_API + "/" + id);
JsonObject jo = jv.asObject();
String title = jo.getString("title", "title");
boolean multiVote = jo.getBoolean("multi", false);
JsonArray jOptions = jo.get("options").asArray();
String[] options = new String[jOptions.size()];
JsonArray jVotes = jo.get("votes").asArray();
int[] votes = new int[jVotes.size()];
for(int i = 0; i < options.length; i++) {
options[i] = jOptions.get(i).asString();
votes[i] = jVotes.get(i).asInt();
}
return new StrawpollObject(title, multiVote, options, votes);
}
示例4: Trip
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public Trip(JPTI jpti, JsonObject json){
this.jpti=jpti;
try{
route=jpti.getRoute(json.getInt(ROUTE,0));
this.traihType=jpti.getTrainType(json.getInt(CLASS,0));
blockID=json.getInt(BLOCK,0);
calender=jpti.calendarList.get(json.getInt(CALENDER,0));
number=json.getString(NUMBER,"");
name=json.getString(NAME,"");
direction=json.getInt(DIRECTION,0);
extraCalendarID=json.getInt(EXTRA_CALENDER,-1);
JsonArray timeArray=json.get(TIME).asArray();
for(int i=0;i<timeArray.size();i++){
Time time=newTime(timeArray.get(i).asObject());
timeList.put(time.getStation(),time);
}
}catch(Exception e){
e.printStackTrace();
}
}
示例5: matchesSafely
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(JsonArray json) {
boolean found = false;
for (int index = 0; index < json.size(); index++) {
final JsonObject jsonMcastRoute = json.get(index).asObject();
final String source = route.source().toString();
final String group = route.group().toString();
final String type = route.type().toString();
final String jsonSource = jsonMcastRoute.get("source").asString();
final String jsonGroup = jsonMcastRoute.get("group").asString();
final String jsonType = jsonMcastRoute.get("type").asString();
if (jsonSource.equals(source) && jsonGroup.equals(group) &&
jsonType.equals(type)) {
found = true;
assertThat(jsonMcastRoute, matchesMcastRoute(route));
}
}
return found;
}
示例6: decomposeJSONValue
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
private void decomposeJSONValue(String name, JsonValue val, Map<String, String> map)
{
if (val.isObject())
{
JsonObject obj = val.asObject();
for (String memberName : obj.names())
{
this.decomposeJSONValue(name + "." + memberName, obj.get(memberName), map);
}
} else if (val.isArray())
{
JsonArray arr = val.asArray();
for (int i = 0; i < arr.size(); i++)
{
this.decomposeJSONValue(name + "[" + i + "]", arr.get(i), map);
}
} else
{
map.put(name, val.toString());
}
}
示例7: matchesSafely
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public boolean matchesSafely(JsonArray json) {
boolean flowFound = false;
for (int jsonFlowIndex = 0; jsonFlowIndex < json.size();
jsonFlowIndex++) {
final JsonObject jsonFlow = json.get(jsonFlowIndex).asObject();
final String flowId = Long.toString(flow.id().value());
final String jsonFlowId = jsonFlow.get("id").asString();
if (jsonFlowId.equals(flowId)) {
flowFound = true;
// We found the correct flow, check attribute values
assertThat(jsonFlow, matchesFlow(flow, APP_ID.name()));
}
}
if (!flowFound) {
reason = "Flow with id " + flow.id().toString() + " not found";
return false;
} else {
return true;
}
}
示例8: getThemeResults
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public static Map<String, ArrayList<Theme>> getThemeResults(String search) throws NoSearchResultException, IOException, NoAPIKeyException {
Map<String, ArrayList<Theme>> toReturn = ExpiringMap.builder()
.expiration(15, TimeUnit.MINUTES)
.build();
String searchUrl = baseThemeUrl + "key=" + Bot.getInstance().getApiKeys().get("themes") + "&search=" + search;
JsonValue jv = Util.jsonFromUrl(searchUrl);
JsonArray ja = jv.asArray();
if(ja.size() == 0) {
throw new NoSearchResultException();
}
for(JsonValue jv2 : ja) {
JsonObject jo = jv2.asObject();
ArrayList<Theme> temp = new ArrayList<Theme>();
for(JsonValue jv3 : jo.get("data").asArray()) {
JsonObject jo2 = jv3.asObject();
temp.add(new Theme(jo.getInt("malId", 1),
jo2.getString("type", "OP"),
jo2.getString("link", "https://my.mixtape.moe/cggknn.webm"),
jo2.getString("songTitle", "Tank!"),
jo.getString("animeName", "Cowboy Bebop")));
}
toReturn.put(jo.getString("animeName", "Cowboy Bebop"), temp);
}
return toReturn;
}
示例9: matchesSafely
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public boolean matchesSafely(JsonArray json) {
boolean intentFound = false;
final int expectedAttributes = 5;
for (int jsonIntentIndex = 0; jsonIntentIndex < json.size();
jsonIntentIndex++) {
final JsonObject jsonIntent = json.get(jsonIntentIndex).asObject();
if (jsonIntent.names().size() != expectedAttributes) {
reason = "Found an intent with the wrong number of attributes";
return false;
}
final String jsonIntentId = jsonIntent.get("id").asString();
if (jsonIntentId.equals(intent.id().toString())) {
intentFound = true;
// We found the correct intent, check attribute values
assertThat(jsonIntent, matchesIntent(intent));
}
}
if (!intentFound) {
reason = "Intent with id " + intent.id().toString() + " not found";
return false;
} else {
return true;
}
}
示例10: parse
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public ItemStackPlaceholder[] parse(JsonValue p4) {
if (p4.isArray()) {
JsonArray jsonArray = p4.asArray();
ItemStackPlaceholder[] itemStacks = new ItemStackPlaceholder[jsonArray.size()];
for (int i = 0; i < itemStacks.length; i++) {
itemStacks[i] = parseSingle(jsonArray.get(i).asObject());
}
return itemStacks;
} else {
return new ItemStackPlaceholder[] { parseSingle(p4.asObject()) };
}
}
示例11: getWalletPublicTransactions
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public synchronized String[][] getWalletPublicTransactions()
throws WalletCallException, IOException, InterruptedException
{
String notListed = "\u26D4";
OS_TYPE os = OSUtil.getOSType();
if (os == OS_TYPE.WINDOWS)
{
notListed = " \u25B6";
}
JsonArray jsonTransactions = executeCommandAndGetJsonArray(
"listtransactions", wrapStringParameter(""), "300");
String strTransactions[][] = new String[jsonTransactions.size()][];
for (int i = 0; i < jsonTransactions.size(); i++)
{
strTransactions[i] = new String[7];
JsonObject trans = jsonTransactions.get(i).asObject();
// Needs to be the same as in getWalletZReceivedTransactions()
// TODO: some day refactor to use object containers
strTransactions[i][0] = "\u2606T (Public)";
strTransactions[i][1] = trans.getString("category", "ERROR!");
strTransactions[i][2] = trans.get("confirmations").toString();
strTransactions[i][3] = trans.get("amount").toString();
strTransactions[i][4] = trans.get("time").toString();
strTransactions[i][5] = trans.getString("address", notListed + " (Z Address not listed by wallet!)");
strTransactions[i][6] = trans.get("txid").toString();
}
return strTransactions;
}
示例12: getWalletZReceivedTransactions
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public synchronized String[][] getWalletZReceivedTransactions()
throws WalletCallException, IOException, InterruptedException
{
String[] zAddresses = this.getWalletZAddresses();
List<String[]> zReceivedTransactions = new ArrayList<String[]>();
for (String zAddress : zAddresses)
{
JsonArray jsonTransactions = executeCommandAndGetJsonArray(
"z_listreceivedbyaddress", wrapStringParameter(zAddress), "0");
for (int i = 0; i < jsonTransactions.size(); i++)
{
String[] currentTransaction = new String[7];
JsonObject trans = jsonTransactions.get(i).asObject();
String txID = trans.getString("txid", "ERROR!");
// Needs to be the same as in getWalletPublicTransactions()
// TODO: some day refactor to use object containers
currentTransaction[0] = "\u2605Z (Private)";
currentTransaction[1] = "receive";
currentTransaction[2] = this.getWalletTransactionConfirmations(txID);
currentTransaction[3] = trans.get("amount").toString();
currentTransaction[4] = this.getWalletTransactionTime(txID); // TODO: minimize sub-calls
currentTransaction[5] = zAddress;
currentTransaction[6] = trans.get("txid").toString();
zReceivedTransactions.add(currentTransaction);
}
}
return zReceivedTransactions.toArray(new String[0][]);
}
示例13: getWalletPublicAddressesWithUnspentOutputs
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public synchronized String[] getWalletPublicAddressesWithUnspentOutputs()
throws WalletCallException, IOException, InterruptedException
{
JsonArray jsonUnspentOutputs = executeCommandAndGetJsonArray("listunspent", "0");
Set<String> addresses = new HashSet<>();
for (int i = 0; i < jsonUnspentOutputs.size(); i++)
{
JsonObject outp = jsonUnspentOutputs.get(i).asObject();
addresses.add(outp.getString("address", "ERROR!"));
}
return addresses.toArray(new String[0]);
}
示例14: matchesSafely
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(JsonObject jsonNode) {
// check master node identifier
String jsonNodeId = jsonNode.get("master") != null ?
jsonNode.get("master").asString() : null;
String nodeId = roleInfo.master().id();
if (!StringUtils.equals(jsonNodeId, nodeId)) {
reason = "master's node id was " + jsonNodeId;
return false;
}
// check backup nodes size
final JsonArray jsonBackupNodeIds = jsonNode.get("backups").asArray();
if (jsonBackupNodeIds.size() != roleInfo.backups().size()) {
reason = "backup nodes size was " + jsonBackupNodeIds.size();
return false;
}
// check backup nodes' identifier
for (NodeId backupNodeId : roleInfo.backups()) {
boolean backupFound = false;
for (int idx = 0; idx < jsonBackupNodeIds.size(); idx++) {
if (backupNodeId.id().equals(jsonBackupNodeIds.get(idx).asString())) {
backupFound = true;
break;
}
}
if (!backupFound) {
reason = "backup not found " + backupNodeId.id();
return false;
}
}
return true;
}
示例15: getWalletZAddresses
import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public synchronized String[] getWalletZAddresses()
throws WalletCallException, IOException, InterruptedException
{
JsonArray jsonAddresses = executeCommandAndGetJsonArray("z_listaddresses", null);
String strAddresses[] = new String[jsonAddresses.size()];
for (int i = 0; i < jsonAddresses.size(); i++)
{
strAddresses[i] = jsonAddresses.get(i).asString();
}
return strAddresses;
}