本文整理匯總了Java中org.jboss.dmr.ModelNode.fromJSONString方法的典型用法代碼示例。如果您正苦於以下問題:Java ModelNode.fromJSONString方法的具體用法?Java ModelNode.fromJSONString怎麽用?Java ModelNode.fromJSONString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jboss.dmr.ModelNode
的用法示例。
在下文中一共展示了ModelNode.fromJSONString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import org.jboss.dmr.ModelNode; //導入方法依賴的package包/類
public static synchronized KubernetesVersion get() {
if (INSTANCE != null) {
return INSTANCE;
}
try {
String versionJson = HttpClient.get(TestConfiguration.masterUrl() + "/version").response();
ModelNode version = ModelNode.fromJSONString(versionJson);
int major = Integer.parseInt(version.get("major").asString());
int minor = Integer.parseInt(version.get("minor").asString());
INSTANCE = new KubernetesVersion(major, minor);
} catch (Exception e) {
LOGGER.error("Error getting Kubernetes version from master", e);
INSTANCE = new KubernetesVersion(0, 0);
}
return INSTANCE;
}
示例2: requestNewToken
import org.jboss.dmr.ModelNode; //導入方法依賴的package包/類
/**
* Request new token from sso instance
*
* @return this instance
* @throws IOException in case of request failure
*/
public TokenHolder requestNewToken() throws IOException {
final String params = buildParams();
final String url = ssoAuthUrl + "/realms/" + realm + "/protocol/openid-connect/token";
log.info("Token request: {}", url);
log.info("Request params: {} ", params);
final String response = HttpClient.post(url)
.data(params, ContentType.APPLICATION_FORM_URLENCODED)
.response();
ModelNode tokenResponse = ModelNode.fromJSONString(response);
log.debug("Token response: {}", tokenResponse);
return new TokenHolder(tokenResponse);
}
示例3: yaml2dmr
import org.jboss.dmr.ModelNode; //導入方法依賴的package包/類
public static ModelNode yaml2dmr(String yaml) throws IOException {
ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
Object obj = yamlMapper.readValue(yaml, Object.class);
ObjectMapper jsonMapper = new ObjectMapper();
String yamlAsJson = jsonMapper.writeValueAsString(obj);
return ModelNode.fromJSONString(yamlAsJson);
}