本文整理汇总了Java中com.badlogic.gdx.utils.JsonValue.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.getChild方法的具体用法?Java JsonValue.getChild怎么用?Java JsonValue.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.JsonValue
的用法示例。
在下文中一共展示了JsonValue.getChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readColorFromJson
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
public static Color readColorFromJson (JsonValue jsonData, String name) {
JsonValue colordata = jsonData.getChild(name);
if (colordata == null)
return Color.BLACK;
float r = 0;
float g = 0;
float b = 0;
float a = 0;
boolean hasnext = true;
while (hasnext) {
if (colordata.name().equals("r"))
r = colordata.asFloat();
else if (colordata.name().equals("g"))
g = colordata.asFloat();
else if (colordata.name().equals("b"))
b = colordata.asFloat();
else if (colordata.name().equals("a"))
a = colordata.asFloat();
colordata = colordata.next();
hasnext = colordata != null;
}
return new Color(r, g, b, a);
}
示例2: getAllImageLinks
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
public static ApiResultState getAllImageLinks(String cacheCode, HashMap<String, URI> list, ICancel icancel) {
ApiResultState chk = chkMembership(false);
if (chk.isErrorState())
return chk;
String URL = Config.StagingAPI.getValue() ? STAGING_GS_LIVE_URL : GS_LIVE_URL;
if (list == null)
list = new HashMap<String, URI>();
waitApiCallLimit();
try {
Net.HttpRequest httpGet = new Net.HttpRequest(Net.HttpMethods.GET);
httpGet.setUrl(URL + "GetImagesForGeocache?AccessToken=" + getAccessToken(true) + "&CacheCode=" + cacheCode + "&format=json");
httpGet.setTimeOut(Config.socket_timeout.getValue());
// Execute HTTP Post Request
log.debug("Send Post request");
String result = (String) NetUtils.postAndWait(NetUtils.ResultType.STRING, httpGet, icancel);
if (result.contains("The service is unavailable")) {
return ApiResultState.API_IS_UNAVAILABLE;
}
JsonValue root = new JsonReader().parse(result);
JsonValue status = root.getChild("Status");
if (status.getInt("StatusCode") == 0) {
LastAPIError = "";
JsonValue jImages = root.getChild("Images");
}
// JSONTokener tokener = new JSONTokener(result);
// JSONObject json = (JSONObject) tokener.nextValue();
// JSONObject status = json.getJSONObject("Status");
// if (status.getInt("StatusCode") == 0) {
// LastAPIError = "";
// JSONArray jImages = json.getJSONArray("Images");
//
// for (int ii = 0; ii < jImages.length(); ii++) {
// JSONObject jImage = (JSONObject) jImages.get(ii);
// String name = jImage.getString("Name");
// String uri = jImage.getString("Url");
// // ignore log images
// if (uri.contains("/cache/log"))
// continue; // LOG-Image
// // Check for duplicate name
// if (list.containsKey(name)) {
// for (int nr = 1; nr < 10; nr++) {
// if (list.containsKey(name + "_" + nr)) {
// continue; // Name already exists
// }
// name += "_" + nr;
// break;
// }
// }
// list.put(name, new URI(uri));
// }
// return IO;
// } else if (status.getInt("StatusCode") == 140) {
// return 140; // API-Limit überschritten -> nach etwas Verzögerung wiederholen!
// } else {
// LastAPIError = "";
// LastAPIError = "StatusCode = " + status.getInt("StatusCode") + "\n";
// LastAPIError += status.getString("StatusMessage") + "\n";
// LastAPIError += status.getString("ExceptionDetails");
//
// list = null;
// return ERROR;
// }
} catch (Exception e) {
log.error("getAllImageLinks()", e);
list = null;
return ApiResultState.API_ERROR;
}
list = null;
return ApiResultState.API_ERROR;
}