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


Java JsonObject.get方法代码示例

本文整理汇总了Java中com.eclipsesource.json.JsonObject.get方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.get方法的具体用法?Java JsonObject.get怎么用?Java JsonObject.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.eclipsesource.json.JsonObject的用法示例。


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

示例1: getSuccessfulOperationTXID

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
public synchronized String getSuccessfulOperationTXID(String opID)
       throws WalletCallException, IOException, InterruptedException
{
	String TXID = null;
	JsonArray response = this.executeCommandAndGetJsonArray(
		"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
	JsonObject jsonStatus = response.get(0).asObject();
	JsonValue  opResultValue = jsonStatus.get("result"); 
	
	if (opResultValue != null)
	{
		JsonObject opResult = opResultValue.asObject();
		if (opResult.get("txid") != null)
		{
			TXID = opResult.get("txid").asString();
		}
	}
	
	return TXID;
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:21,代码来源:ZCashClientCaller.java

示例2: testConfigs

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
/**
 * Tests the result of the rest api GET when there is a config.
 */
@Test
public void testConfigs() {
    setUpConfigData();
    final WebTarget wt = target();
    final String response = wt.path("network/configuration").request().get(String.class);

    final JsonObject result = Json.parse(response).asObject();
    Assert.assertThat(result, notNullValue());

    Assert.assertThat(result.names(), hasSize(2));

    JsonValue devices = result.get("devices");
    Assert.assertThat(devices, notNullValue());

    JsonValue device1 = devices.asObject().get("device1");
    Assert.assertThat(device1, notNullValue());

    JsonValue basic = device1.asObject().get("basic");
    Assert.assertThat(basic, notNullValue());

    checkBasicAttributes(basic);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:NetworkConfigWebResourceTest.java

示例3: parseStack

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
public static ItemStack parseStack(JsonValue js) {
	if (js.isString()) {
		return new ItemStack(getItem(js.asString()));
	} else if (js.isObject()) {
		JsonObject obj = js.asObject();
		JsonValue id = obj.get("id");
		if (id == null)
			throw new JsonException("No id");
		return new ItemStack(getItem(id.asString()), obj.getInt("count", 1), obj.getInt("meta", 0));
	} else if (js.isNull()) {
		return null;
	}
	throw new JsonException("Invalid type " + js.toString());
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:15,代码来源:RecipeJson.java

示例4: addItem

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
public static void addItem(JsonObject js) {
	if (js.get("tool") != null) {
		addItemTool(js);
		return;
	}
	String id = json.getString("id", null);
	if (id == null)
		throw new JsonException("No item id");
	JItem item = new JItem(id);

	JsonValue prop;

	prop = js.get("texture");
	if (prop != null) {
		item.textureString = prop.asString();
	} else {
		item.textureString = id;
	}

	for (JsonObject.Member member : js) {
		switch (member.getName()) {
		case "id":
		case "texture":
			break;
		default:
			throw new JsonException("Unexpected block member \"" + member.getName() + "\"");
		}
	}

	IDManager.register(item);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:32,代码来源:ItemJson.java

示例5: addItemTool

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
public static void addItemTool(JsonObject js) {
	String id = js.getString("id", null);
	if (id == null) {
		throw new JsonException("No item id");
	}
	JItemTool item = new JItemTool(id);

	JsonObject tool = js.get("tool").asObject();

	addItemToolFor(tool, item);

	JsonValue prop;

	prop = js.get("texture");
	if (prop != null) {
		item.textureString = prop.asString();
	} else {
		item.textureString = id;
	}

	for (JsonObject.Member member : js) {
		switch (member.getName()) {
		case "id":
		case "texture":
		case "tool":
			break;
		default:
			throw new JsonException("Unexpected block member \"" + member.getName() + "\"");
		}
	}

	IDManager.register(item);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:34,代码来源:ItemJson.java

示例6: addBlock

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
public static void addBlock(JsonObject jsB) {
	String id = jsB.getString("id", null);
	if (id == null)
		throw new JsonException("No block id");
	int meta = jsB.getInt("meta", 1);
	JBlock block = new JBlock(id, meta);

	block.textures = parseMetaElement(jsB, "texture", new String[meta][], textureParser);
	block.lightLevel = parseMetaElement(jsB, "lightLevel", new Integer[meta], integerParser);
	block.transparent = parseMetaElement(jsB, "transparent", new Boolean[meta], booleanParser);
	block.drops = parseMetaElement(jsB, "drops", new ItemStackPlaceholder[meta][], itemStackArrayParser);

	JsonValue prop;

	prop = jsB.get("displayMeta");
	addBlockDisplay(prop, block, meta);

	prop = jsB.get("mining");
	addBlockMining(prop, block);

	for (JsonObject.Member member : jsB) {
		addBlockSwitch(member);
	}

	block.jsonFinish();
	IDManager.register(block);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:28,代码来源:BlockJson.java

示例7: parseMetaElement

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
private static <T> T[] parseMetaElement(JsonObject jsP, String name, T[] t, MetaElementParser<T> parser) {
	JsonValue j = jsP.get(name);
	if (j == null)
		return null;
	if (!j.isObject() || t.length == 1) {
		Arrays.fill(t, parser.parse(j));
	} else {
		JsonObject jsonObject = j.asObject();
		T defaultT = null;
		try {
			for (Member member : jsonObject) {
				String s = member.getName();
				if (s.equals("default")) {
					defaultT = parser.parse(member.getValue());
					continue;
				}
				int m = -1;

				m = Integer.parseInt(s);
				t[m] = null; // catch out of range exceptions

				t[m] = parser.parse(member.getValue());
			}
		} catch (Exception e) {
			throw new JsonException("Unexpected " + name + " member \"" + member.getName() + "\"");
		}
		parseMetaElementFor(t, defaultT, name);
	}
	return t;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:31,代码来源:BlockJson.java

示例8: isZENIdentityMessage

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
/**
 * Checks if a message contains a ZEN messaging identity in it.
 * 
 * @param message
 * 
 * @return true if a ZEN identity is inside
 */
public boolean isZENIdentityMessage(String message)
{
	if (message == null)
	{
		return false;
	}
	
	if (!message.trim().startsWith("{"))
	{
		return false;
	}
	
	JsonObject jsonMessage = null;
	try
	{
		jsonMessage = Util.parseJsonObject(message);
	} catch (Exception ex)
	{
		return false;
	}
	
	if (jsonMessage.get("zenmessagingidentity") == null)
	{
		return false;
	}
	
	JsonObject innerMessage = jsonMessage.get("zenmessagingidentity").asObject();
	if ((innerMessage.get("nickname") == null)           ||
		(innerMessage.get("sendreceiveaddress") == null) ||
		(innerMessage.get("senderidaddress") == null))
	{
		return false;
	}
	
	// All conditions met - return true
	return true;
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:45,代码来源:MessagingPanel.java

示例9: copyFromJSONObject

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
public void copyFromJSONObject(JsonObject obj)
{
	// Wire protocol fields
	this.version       = obj.getInt("ver",              1);
	this.from          = obj.getString("from",          "");
	this.message       = obj.getString("message",       "");
	this.sign          = obj.getString("sign",          "");
	this.threadID      = obj.getString("threadid",      "");	
	this.returnAddress = obj.getString("returnaddress", "");
	
	// Additional fields - may be missing, get default values
	this.transactionID = obj.getString("transactionID", "");
	this.time          = new Date(obj.getLong("time",   0));
	this.direction     = DIRECTION_TYPE.valueOf(
			                 obj.getString("direction", DIRECTION_TYPE.RECEIVED.toString()));
	this.verification  = VERIFICATION_TYPE.valueOf(
			                 obj.getString("verification", VERIFICATION_TYPE.UNVERIFIED.toString()));
	
	if (obj.get("isanonymous") != null)
	{
		this.isAnonymous = obj.getBoolean("isanonymous", false);
	} else
	{
		// Determine from content if it is anonymous
		this.isAnonymous = obj.get("threadid") != null; 
	}
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:28,代码来源:Message.java

示例10: load

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
/**
 * Load from configuration.
 */
public void load() {
	// Return if the config file does not exist.
	if (!confFile.exists()) {
		return;
	}
	try {
		JsonObject json = Json.parse(Files.readFile(confFile.getAbsolutePath())).asObject();
		for (Field field : this.getClass().getDeclaredFields()) {
			String name = field.getName();
			JsonValue value = json.get(name);
			if (value == null) {
				continue;
			}
			field.setAccessible(true);
			if (value.isBoolean()) {
				field.set(this, value.asBoolean());
			} else if (value.isNumber()) {
				field.set(this, value.asInt());
			} else if (value.isString()) {
				field.set(this, value.asString());
			} else {
				Object parsed = parse(field.getType(), value);
				if (parsed != null) {
					field.set(this, parsed);
				}
			}
		}
	} catch (Exception e) {
		Recaf.INSTANCE.logging.error(e, false);
	}
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:35,代码来源:Config.java

示例11: parseStack

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
public static ItemStack parseStack(JsonValue json) {
  if (json.isString()) {
    return new ItemStack(getItem(json.asString()));
  } else if (json.isObject()) {
    JsonObject obj = json.asObject();
    JsonValue id = obj.get("id");
    if (id == null) throw new JsonException("No id");
    return new ItemStack(getItem(id.asString()), obj.getInt("count", 1), obj.getInt("meta", 0));
  } else if (json.isNull()) {
    return null;
  }
  throw new JsonException("Invalid type " + json.toString());
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:14,代码来源:RecipeJson.java

示例12: addItem

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
public static void addItem(JsonObject json) {
  if (json.get("tool") != null) {
    addItemTool(json);
    return;
  }
  String id = json.getString("id", null);
  if (id == null) throw new JsonException("No item id");
  JItem item = new JItem(id);

  JsonValue prop;

  prop = json.get("texture");
  if (prop != null) {
    item.textureString = prop.asString();
  } else {
    item.textureString = id;
  }

  for (JsonObject.Member member : json) {
    switch (member.getName()) {
      case "id":
      case "texture":
        break;
      default:
        throw new JsonException("Unexpected block member \"" + member.getName() + "\"");
    }
  }

  IDManager.register(item);
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:31,代码来源:ItemJson.java

示例13: parseMetaElement

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
private static <T> T[] parseMetaElement(JsonObject json, String name, T[] t, MetaElementParser<T> parser) {
  JsonValue j = json.get(name);
  if (j == null) return null;
  if (!j.isObject() || t.length == 1) {
    Arrays.fill(t, parser.parse(j));
  } else {
    JsonObject jsonObject = j.asObject();
    T defaultT = null;
    for (Member member : jsonObject) {
      String s = member.getName();
      if (s.equals("default")) {
        defaultT = parser.parse(member.getValue());
        continue;
      }
      int m = -1;
      try {
        m = Integer.parseInt(s);
        t[m] = null; // catch out of range exceptions
      } catch (Exception e) {
        throw new JsonException("Unexpected " + name + " member \"" + member.getName() + "\"");
      }
      t[m] = parser.parse(member.getValue());
    }
    for (int i = 0; i < t.length; i++) {
      if (t[i] == null) {
        if (defaultT == null) {
          throw new JsonException(name + " for meta " + i + " not defined");
        } else {
          t[i] = defaultT;
        }
      }
    }
  }
  return t;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:36,代码来源:BlockJson.java

示例14: matchesSafely

import com.eclipsesource.json.JsonObject; //导入方法依赖的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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:MastershipResourceTest.java

示例15: fetchCpeLocation

import com.eclipsesource.json.JsonObject; //导入方法依赖的package包/类
private void fetchCpeLocation(VoltTenant newTenant, String jsonString) {
    JsonObject json = JsonObject.readFrom(jsonString);

    if (json.get("computeNodeName") != null) {
        ConnectPoint point = nodeToPort.get(json.get("computeNodeName").asString());
        //ConnectPoint fromPoint = newTenant.port();
        ConnectPoint oltPort = new ConnectPoint(FABRIC_DEVICE_ID, FABRIC_OLT_CONNECT_POINT);

        provisionFabric(VlanId.vlanId(Short.parseShort(newTenant.vlanId())),
                        point, oltPort);
    }

}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:OnosXosIntegrationManager.java


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