本文整理汇总了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);
}