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