本文整理匯總了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;
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}