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


Java JsonValue.asObject方法代码示例

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


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

示例1: getSuccessfulOperationTXID

import com.eclipsesource.json.JsonValue; //导入方法依赖的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: decomposeJSONValue

import com.eclipsesource.json.JsonValue; //导入方法依赖的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());
	}
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:22,代码来源:ZCashClientCaller.java

示例3: fromId

import com.eclipsesource.json.JsonValue; //导入方法依赖的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);
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:23,代码来源:StrawpollObject.java

示例4: parseStack

import com.eclipsesource.json.JsonValue; //导入方法依赖的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

示例5: parseMetaElement

import com.eclipsesource.json.JsonValue; //导入方法依赖的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

示例6: parse

import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
@Override
public String[] parse(JsonValue p3) {
	String[] textures = new String[6];
	if (p3.isString()) {
		Arrays.fill(textures, p3.asString());
	} else {
		JsonObject texture = p3.asObject();
		for (JsonObject.Member member : texture) {
			String value = member.getValue().asString();
			parseSwitch(member, textures, value);
		}
	}
	return textures;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:15,代码来源:BlockJson.java

示例7: executeCommandAndGetJsonObject

import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
private JsonObject executeCommandAndGetJsonObject(String command1, String command2)
	throws WalletCallException, IOException, InterruptedException
{
	JsonValue response = this.executeCommandAndGetJsonValue(command1, command2);

	if (response.isObject())
	{
		return response.asObject();
	} else
	{
		throw new WalletCallException("Unexpected non-object response from wallet: " + response.toString());
	}

}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:15,代码来源:ZCashClientCaller.java

示例8: parseStack

import com.eclipsesource.json.JsonValue; //导入方法依赖的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

示例9: parseMetaElement

import com.eclipsesource.json.JsonValue; //导入方法依赖的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

示例10: getThemeResults

import com.eclipsesource.json.JsonValue; //导入方法依赖的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;
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:28,代码来源:Theme.java

示例11: parse

import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
@Override
public String[] parse(JsonValue prop) {
  String[] textures = new String[6];
  if (prop.isString()) {
    Arrays.fill(textures, prop.asString());
  } else {
    JsonObject texture = prop.asObject();
    for (JsonObject.Member member : texture) {
      String value = member.getValue().asString();
      switch (member.getName()) {
        case "posX":
          textures[BlockFace.posX.index] = value;
          break;
        case "negX":
          textures[BlockFace.negX.index] = value;
          break;
        case "posY":
        case "top":
          textures[BlockFace.posY.index] = value;
          break;
        case "negY":
        case "bottom":
          textures[BlockFace.negY.index] = value;
          break;
        case "posZ":
          textures[BlockFace.posZ.index] = value;
          break;
        case "negZ":
          textures[BlockFace.negZ.index] = value;
          break;
        case "side":
          textures[BlockFace.posX.index] = value;
          textures[BlockFace.negX.index] = value;
          textures[BlockFace.posZ.index] = value;
          textures[BlockFace.negZ.index] = value;
          break;
        case "other":
          for (int i = 0; i < textures.length; i++) {
            if (textures[i] == null) textures[i] = value;
          }
          break;
        default:
          throw new JsonException("Unexpected block texture member \"" + member.getName() + "\"");
      }
    }
  }
  return textures;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:49,代码来源:BlockJson.java

示例12: WoWCharacter

import com.eclipsesource.json.JsonValue; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public WoWCharacter(String server, String name, String region) throws IOException, BadCharacterException, NoAPIKeyException {
	String apiKey;
	region = region.replace("na", "us");
	apiKey = Bot.getInstance().getApiKeys().get("battlenet");
	JsonObject jo = Util.jsonFromUrl((String.format(baseUrl, region)
			+ server + "/" + name + "?fields=statistics,progression,guild,items&apikey=" + apiKey)
			.replaceAll(" ", "%20")).asObject();
	if(!(jo.get("status") == null)) {
		if(jo.get("status").asString().equals("nok")) {
			throw new BadCharacterException();
		}
	}

	//Raid progression
	for(JsonValue jv : jo.get("progression").asObject().get("raids").asArray()) {
		JsonObject j = jv.asObject();
		lfrRaid += j.get("lfr").asInt();
		normalRaid += j.get("normal").asInt();
		heroicRaid += j.get("heroic").asInt();
		mythicRaid += j.get("mythic").asInt();
		for(JsonValue jv2 : j.get("bosses").asArray()) {
			JsonObject j2 = jv2.asObject();
			lfrKills += j2.getInt("lfrKills", 0);
			normalKills += j2.getInt("normalKills", 0);
			heroicKills += j2.getInt("heroicKills", 0);
			mythicKills += j2.getInt("mythicKills", 0);
		}
	}

	this.username = jo.get("name").asString();
	this.realm = jo.get("realm").asString();
	this.gender = (jo.get("gender").asInt() == 0 ? "Male" : "Female");
	this.gameClass = ((HashMap<Integer, String>) cache.get("wowclasses")).get(jo.get("class").asInt());
	this.race = ((HashMap<Integer, String>) cache.get("wowraces")).get(jo.get("race").asInt());
	this.level = jo.get("level").asInt();
	this.achievementPoints = jo.get("achievementPoints").asInt();
	this.itemLevel = jo.get("items").asObject().get("averageItemLevel").asInt();
	
	if(jo.get("guild") != null) {
		this.guild = jo.get("guild").asObject().getString("name", null);
		this.guildMembers = jo.get("guild").asObject().get("members").asInt();
	} else {
		this.guild = null;
	}

	this.thumbnail = jo.get("thumbnail").asString();
	this.thumbnail = thumbnail.replace("avatar", "profilemain");
	this.thumbnail = String.format("http://render-%s.worldofwarcraft.com/character/%s", region, thumbnail);
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:51,代码来源:WoWCharacter.java


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