本文整理了Java中javax.json.Json.createValue()
方法的一些代码示例,展示了Json.createValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.createValue()
方法的具体详情如下:
包路径:javax.json.Json
类名称:Json
方法名:createValue
[英]Creates a JsonNumber.
[中]创建一个JsonNumber。
代码示例来源:origin: oracle/helidon
private Optional<JsonValue> getJsonValue(String claimName) {
if (Claims.raw_token.name().equals(claimName)) {
// special case, raw token is not really a claim
return Optional.of(Json.createValue(signed.tokenContent()));
}
return OptionalHelper
.from(jwt.payloadClaim(claimName))
.or(() -> jwt.headerClaim(claimName))
.asOptional();
}
代码示例来源:origin: kitodo/kitodo-production
/**
* Method used for formatting Date as JsonValue. It will help to change fast a
* way of Date formatting or expected String format.
*
* @param date
* as Date
* @return formatted date as JsonValue - String or NULL
*/
JsonValue getFormattedDate(Date date) {
if (Objects.nonNull(date)) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return Json.createValue(dateFormat.format(date));
}
return JsonValue.NULL;
}
代码示例来源:origin: osgi/osgi.enroute
private JsonValue toJsonValue(Object value, Type targetType) {
if (value == null) {
return JsonValue.NULL;
} else if (value instanceof String) {
return Json.createValue(value.toString());
} else if (value instanceof Boolean) {
return ((Boolean) value) ? JsonValue.TRUE : JsonValue.FALSE;
} else if (value instanceof Number) {
Number n = (Number) value;
if (value instanceof Float || value instanceof Double) {
return Json.createValue(n.doubleValue());
} else if (value instanceof BigDecimal) {
return Json.createValue((BigDecimal) value);
} else if (value instanceof BigInteger) {
return Json.createValue((BigInteger) value);
} else {
return Json.createValue(n.longValue());
}
} else if (value instanceof Collection || value.getClass().isArray()) {
return toJsonArray(value);
} else {
return toJsonObject(value);
}
}
代码示例来源:origin: io.helidon.security/helidon-security-jwt
private static JsonValue toJson(Object object) {
if (object instanceof String) {
return Json.createValue((String) object);
}
if (object instanceof Integer) {
return Json.createValue((Integer) object);
}
if (object instanceof Double) {
return Json.createValue((Double) object);
}
if (object instanceof Long) {
return Json.createValue((Long) object);
}
if (object instanceof BigDecimal) {
return Json.createValue((BigDecimal) object);
}
if (object instanceof BigInteger) {
return Json.createValue((BigInteger) object);
}
if (object instanceof Boolean) {
return ((Boolean) object) ? JsonValue.TRUE : JsonValue.FALSE;
}
if (object instanceof Address) {
return ((Address) object).getJson();
}
if (object instanceof Collection) {
return Json.createArrayBuilder((Collection) object).build();
}
return Json.createValue(String.valueOf(object));
}
代码示例来源:origin: org.osgi.enroute.examples.microservice/rest-service
private JsonValue toJsonValue(Object value, Type targetType) {
if (value == null) {
return JsonValue.NULL;
} else if (value instanceof String) {
return Json.createValue(value.toString());
} else if (value instanceof Boolean) {
return ((Boolean) value) ? JsonValue.TRUE : JsonValue.FALSE;
} else if (value instanceof Number) {
Number n = (Number) value;
if (value instanceof Float || value instanceof Double) {
return Json.createValue(n.doubleValue());
} else if (value instanceof BigDecimal) {
return Json.createValue((BigDecimal) value);
} else if (value instanceof BigInteger) {
return Json.createValue((BigInteger) value);
} else {
return Json.createValue(n.longValue());
}
} else if (value instanceof Collection || value.getClass().isArray()) {
return toJsonArray(value);
} else {
return toJsonObject(value);
}
}
代码示例来源:origin: io.helidon.microprofile.jwt/helidon-microprofile-jwt-auth
private Optional<JsonValue> getJsonValue(String claimName) {
if (Claims.raw_token.name().equals(claimName)) {
// special case, raw token is not really a claim
return Optional.of(Json.createValue(signed.tokenContent()));
}
return OptionalHelper
.from(jwt.payloadClaim(claimName))
.or(() -> jwt.headerClaim(claimName))
.asOptional();
}
内容来源于网络,如有侵权,请联系作者删除!