當前位置: 首頁>>代碼示例>>Java>>正文


Java ModelNode.fromJSONString方法代碼示例

本文整理匯總了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;
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:19,代碼來源:KubernetesVersion.java

示例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);
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:22,代碼來源:SsoTokenRequestor.java

示例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);
}
 
開發者ID:xtf-cz,項目名稱:xtf,代碼行數:10,代碼來源:YamlUtils.java


注:本文中的org.jboss.dmr.ModelNode.fromJSONString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。