Package net.royalur.notation
Class JsonHelper
java.lang.Object
net.royalur.notation.JsonHelper
Contains type checking helper methods for retrieving JSON values,
as Jackson doesn't support that for some reason.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.databind.node.ArrayNode
checkedToArray
(com.fasterxml.jackson.databind.JsonNode value, String key) static boolean
checkedToBool
(com.fasterxml.jackson.databind.JsonNode value, String key) static char
checkedToChar
(String value, String key) static double
checkedToDouble
(com.fasterxml.jackson.databind.JsonNode value, String key) static float
checkedToFloat
(com.fasterxml.jackson.databind.JsonNode value, String key) static int
checkedToInt
(com.fasterxml.jackson.databind.JsonNode value, String key) static long
checkedToLong
(com.fasterxml.jackson.databind.JsonNode value, String key) static com.fasterxml.jackson.databind.JsonNode
checkedToNumber
(com.fasterxml.jackson.databind.JsonNode value, String key) static com.fasterxml.jackson.databind.node.ObjectNode
checkedToObject
(com.fasterxml.jackson.databind.JsonNode value, String key) static String
checkedToString
(com.fasterxml.jackson.databind.JsonNode value, String key) static String
encodeDate
(Instant instant) static String
encodeNullableDate
(Instant instant) static Instant
static com.fasterxml.jackson.databind.node.ArrayNode
static com.fasterxml.jackson.databind.JsonNode
readArrayEntry
(com.fasterxml.jackson.databind.node.ArrayNode json, int index) static com.fasterxml.jackson.databind.node.ObjectNode
readArrayObjectEntry
(com.fasterxml.jackson.databind.node.ArrayNode json, int index) static boolean
static boolean
readBoolWithDefault
(com.fasterxml.jackson.databind.node.ObjectNode json, String key, boolean defaultValue) static char
static char
readCharWithDefault
(com.fasterxml.jackson.databind.node.ObjectNode json, String key, char defaultValue) static Instant
Reads an ISO date string.static Instant
readDateWithDefault
(com.fasterxml.jackson.databind.node.ObjectNode json, String key, Instant defaultValue) Reads an ISO date string.static double
readDouble
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static double
readDoubleWithDefault
(com.fasterxml.jackson.databind.node.ObjectNode json, String key, double defaultValue) static float
static float
readFloatWithDefault
(com.fasterxml.jackson.databind.node.ObjectNode json, String key, float defaultValue) static int
static int
readIntWithDefault
(com.fasterxml.jackson.databind.node.ObjectNode json, String key, int defaultValue) static long
static long
readLongWithDefault
(com.fasterxml.jackson.databind.node.ObjectNode json, String key, long defaultValue) static com.fasterxml.jackson.databind.node.ArrayNode
readNullableArray
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static Boolean
readNullableBool
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static Character
readNullableChar
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static Instant
readNullableDate
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) Reads an ISO date string.static Double
readNullableDouble
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static Float
readNullableFloat
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static Integer
readNullableInt
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static Long
readNullableLong
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static com.fasterxml.jackson.databind.JsonNode
readNullableNumber
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static com.fasterxml.jackson.databind.node.ObjectNode
readNullableObject
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static String
readNullableString
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static com.fasterxml.jackson.databind.JsonNode
readNullableValue
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static com.fasterxml.jackson.databind.JsonNode
readNumber
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static com.fasterxml.jackson.databind.node.ObjectNode
readObject
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static String
readString
(com.fasterxml.jackson.databind.node.ObjectNode json, String key) static String
readStringWithDefault
(com.fasterxml.jackson.databind.node.ObjectNode json, String key, String defaultValue) static com.fasterxml.jackson.databind.JsonNode
-
Field Details
-
MAX_FLOAT_READ_EPSILON
public static final double MAX_FLOAT_READ_EPSILON- See Also:
-
MAX_DOUBLE_READ_EPSILON
-
-
Method Details
-
readNullableValue
@Nullable public static com.fasterxml.jackson.databind.JsonNode readNullableValue(com.fasterxml.jackson.databind.node.ObjectNode json, String key) -
readValue
public static com.fasterxml.jackson.databind.JsonNode readValue(com.fasterxml.jackson.databind.node.ObjectNode json, String key) -
checkedToObject
public static com.fasterxml.jackson.databind.node.ObjectNode checkedToObject(com.fasterxml.jackson.databind.JsonNode value, String key) -
readObject
public static com.fasterxml.jackson.databind.node.ObjectNode readObject(com.fasterxml.jackson.databind.node.ObjectNode json, String key) -
readNullableObject
@Nullable public static com.fasterxml.jackson.databind.node.ObjectNode readNullableObject(com.fasterxml.jackson.databind.node.ObjectNode json, String key) -
checkedToArray
public static com.fasterxml.jackson.databind.node.ArrayNode checkedToArray(com.fasterxml.jackson.databind.JsonNode value, String key) -
readArray
public static com.fasterxml.jackson.databind.node.ArrayNode readArray(com.fasterxml.jackson.databind.node.ObjectNode json, String key) -
readNullableArray
@Nullable public static com.fasterxml.jackson.databind.node.ArrayNode readNullableArray(com.fasterxml.jackson.databind.node.ObjectNode json, String key) -
readArrayEntry
public static com.fasterxml.jackson.databind.JsonNode readArrayEntry(com.fasterxml.jackson.databind.node.ArrayNode json, int index) -
readArrayObjectEntry
public static com.fasterxml.jackson.databind.node.ObjectNode readArrayObjectEntry(com.fasterxml.jackson.databind.node.ArrayNode json, int index) -
checkedToString
-
readString
-
readNullableString
-
readStringWithDefault
-
checkedToChar
-
readChar
-
readNullableChar
-
readCharWithDefault
public static char readCharWithDefault(com.fasterxml.jackson.databind.node.ObjectNode json, String key, char defaultValue) -
checkedToNumber
public static com.fasterxml.jackson.databind.JsonNode checkedToNumber(com.fasterxml.jackson.databind.JsonNode value, String key) -
readNumber
public static com.fasterxml.jackson.databind.JsonNode readNumber(com.fasterxml.jackson.databind.node.ObjectNode json, String key) -
readNullableNumber
@Nullable public static com.fasterxml.jackson.databind.JsonNode readNullableNumber(com.fasterxml.jackson.databind.node.ObjectNode json, String key) -
checkedToInt
-
readInt
-
readNullableInt
-
readIntWithDefault
public static int readIntWithDefault(com.fasterxml.jackson.databind.node.ObjectNode json, String key, int defaultValue) -
checkedToLong
-
readLong
-
readNullableLong
-
readLongWithDefault
public static long readLongWithDefault(com.fasterxml.jackson.databind.node.ObjectNode json, String key, long defaultValue) -
checkedToFloat
-
readFloat
-
readNullableFloat
-
readFloatWithDefault
public static float readFloatWithDefault(com.fasterxml.jackson.databind.node.ObjectNode json, String key, float defaultValue) -
checkedToDouble
-
readDouble
-
readNullableDouble
-
readDoubleWithDefault
public static double readDoubleWithDefault(com.fasterxml.jackson.databind.node.ObjectNode json, String key, double defaultValue) -
checkedToBool
-
readBool
-
readNullableBool
-
readBoolWithDefault
public static boolean readBoolWithDefault(com.fasterxml.jackson.databind.node.ObjectNode json, String key, boolean defaultValue) -
parseDate
-
encodeDate
-
encodeNullableDate
-
readDate
Reads an ISO date string. -
readNullableDate
@Nullable public static Instant readNullableDate(com.fasterxml.jackson.databind.node.ObjectNode json, String key) Reads an ISO date string. -
readDateWithDefault
public static Instant readDateWithDefault(com.fasterxml.jackson.databind.node.ObjectNode json, String key, Instant defaultValue) Reads an ISO date string.
-