diff --git a/implementation/jwt-auth/src/main/java/io/smallrye/jwt/JsonUtils.java b/implementation/jwt-auth/src/main/java/io/smallrye/jwt/JsonUtils.java index b112529c..2bd3469c 100644 --- a/implementation/jwt-auth/src/main/java/io/smallrye/jwt/JsonUtils.java +++ b/implementation/jwt-auth/src/main/java/io/smallrye/jwt/JsonUtils.java @@ -6,7 +6,6 @@ import java.util.Map; import java.util.Set; -import jakarta.json.Json; import jakarta.json.JsonArray; import jakarta.json.JsonArrayBuilder; import jakarta.json.JsonNumber; @@ -14,14 +13,17 @@ import jakarta.json.JsonObjectBuilder; import jakarta.json.JsonString; import jakarta.json.JsonValue; +import jakarta.json.spi.JsonProvider; public class JsonUtils { + private static final JsonProvider JSON_PROVIDER = JsonProvider.provider(); + private JsonUtils() { } public static JsonObject replaceMap(Map map) { - JsonObjectBuilder builder = Json.createObjectBuilder(); + JsonObjectBuilder builder = JSON_PROVIDER.createObjectBuilder(); for (Map.Entry entry : map.entrySet()) { Object entryValue = entry.getValue(); if (entryValue instanceof Map) { @@ -48,7 +50,7 @@ public static JsonObject replaceMap(Map map) { } private static JsonArray toJsonArray(Collection collection) { - JsonArrayBuilder arrayBuilder = Json.createArrayBuilder(); + JsonArrayBuilder arrayBuilder = JSON_PROVIDER.createArrayBuilder(); for (Object element : collection) { if (element instanceof String) { @@ -71,11 +73,11 @@ public static JsonValue wrapValue(Object value) { // This may already be a JsonValue jsonValue = (JsonValue) value; } else if (value instanceof String) { - jsonValue = Json.createValue(value.toString()); + jsonValue = JSON_PROVIDER.createValue(value.toString()); } else if ((value instanceof Long) || (value instanceof Integer)) { - jsonValue = Json.createValue(((Number) value).longValue()); + jsonValue = JSON_PROVIDER.createValue(((Number) value).longValue()); } else if (value instanceof Number) { - jsonValue = Json.createValue(((Number) value).doubleValue()); + jsonValue = JSON_PROVIDER.createValue(((Number) value).doubleValue()); } else if (value instanceof Boolean) { jsonValue = (Boolean) value ? JsonValue.TRUE : JsonValue.FALSE; } else if (value instanceof Collection) {