本文整理汇总了Java中com.google.api.client.json.GenericJson.get方法的典型用法代码示例。如果您正苦于以下问题:Java GenericJson.get方法的具体用法?Java GenericJson.get怎么用?Java GenericJson.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.json.GenericJson
的用法示例。
在下文中一共展示了GenericJson.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getForecastString
import com.google.api.client.json.GenericJson; //导入方法依赖的package包/类
private List<String> getForecastString(GenericJson content) {
List<String> response = Lists.newArrayList();
StringBuilder respLin = new StringBuilder();
try {
ArrayMap forecast = (ArrayMap) content.get("forecast");
ArrayMap simpleforecast = (ArrayMap) forecast.get("simpleforecast");
ArrayList forecastday = (ArrayList) simpleforecast.get("forecastday");
Iterator iterator = forecastday.iterator();
while (iterator.hasNext()) {
ArrayMap day = (ArrayMap) iterator.next();
ArrayMap date = (ArrayMap) day.get("date");
ArrayMap high = (ArrayMap) day.get("high");
ArrayMap low = (ArrayMap) day.get("low");
String conditions = (String) day.get("conditions");
respLin.append(date.get("weekday_short")).append(" ").append((String)high.get("fahrenheit")).append("F/").append((String)low.get("fahrenheit")).append("F ").append("(").append(conditions).append(")").append(" | ");
}
} catch (Exception e) {
log.error("Error obtaining weather!", e);
}
String finalstring = respLin.toString().substring(0, respLin.toString().length() - 2);
response.add(finalstring);
return response;
}
示例2: getCurrentConditionsString
import com.google.api.client.json.GenericJson; //导入方法依赖的package包/类
private List<String> getCurrentConditionsString(GenericJson content) {
List<String> response = Lists.newArrayList();
try {
ArrayMap current_observation = (ArrayMap) content.get("current_observation");
Object weather = current_observation.get("weather");
Object temperature_string = current_observation.get("temperature_string");
Object wind_string = current_observation.get("wind_string");
Object relative_humidity = current_observation.get("relative_humidity");
Object feelslike_string = current_observation.get("feelslike_string");
ArrayMap display_location = (ArrayMap) current_observation.get("display_location");
Object full = display_location.get("full");
response.add(full.toString() + ": " + weather + " | Temperature: " + temperature_string + " | Humidity: " + relative_humidity + " | Feels Like: " + feelslike_string + " | Wind: " + wind_string);
} catch (Exception e) {
log.error("Error obtaining weather!", e);
}
return response;
}
示例3: createUser
import com.google.api.client.json.GenericJson; //导入方法依赖的package包/类
String createUser(CreateRequest request) throws FirebaseAuthException {
GenericJson response = post(
"signupNewUser", request.getProperties(), GenericJson.class);
if (response != null) {
String uid = (String) response.get("localId");
if (!Strings.isNullOrEmpty(uid)) {
return uid;
}
}
throw new FirebaseAuthException(INTERNAL_ERROR, "Failed to create new user");
}
示例4: parseJoke
import com.google.api.client.json.GenericJson; //导入方法依赖的package包/类
private List<String> parseJoke(GenericJson content) {
List<String> response = Lists.newArrayList();
try {
ArrayMap current_observation = (ArrayMap) content.get("value");
Object joke = current_observation.get("joke");
response.add(joke.toString());
} catch (Exception e) {
log.error("Error obtaining chuck norris joke!", e);
}
return response;
}
示例5: parseDefinition
import com.google.api.client.json.GenericJson; //导入方法依赖的package包/类
private List<String> parseDefinition(GenericJson content) {
List<String> response = Lists.newArrayList();
try {
ArrayList definitions = (ArrayList) content.get("definitions");
ArrayMap definition = (ArrayMap) definitions.get(0);
Object text = definition.get("text");
response.add(text.toString());
} catch (Exception e) {
log.error("Error obtaining definition!", e);
}
return response;
}
示例6: run
import com.google.api.client.json.GenericJson; //导入方法依赖的package包/类
private static void run() throws Exception {
HttpRequestFactory requestFactory = HTTP_TRANSPORT
.createRequestFactory(new HttpRequestInitializer() {
public void initialize(HttpRequest request) {
request.setParser(new JsonObjectParser(JSON_FACTORY));
}
});
GenericUrl urlBlockchain = new GenericUrl(EXURL_BLOCKCHAIN);
GenericUrl urlYahooTwd = new GenericUrl(EXURL_YAHOO_USDTWD);
HttpRequest requestBlockChain = requestFactory.buildGetRequest(urlBlockchain);
GenericJson json = requestBlockChain.execute().parseAs(GenericJson.class);
System.out.println(json);
Map ntdJson = (Map) json.get("USD");
System.out.println(ntdJson.put("buy", 119.001));
json.put("NTD", ntdJson);
System.out.println(json);
HttpRequest requestYahoo = requestFactory.buildGetRequest(urlYahooTwd);
GenericJson jsonYahoo = requestYahoo.execute().parseAs(GenericJson.class);
System.out.println(jsonYahoo);
Map query = (Map) jsonYahoo.get("query");
Map results = (Map) query.get("results");
Map row = (Map) results.get("row");
double twd = Double.parseDouble((String)row.get("col1"));
System.out.println(twd);
}