Package com.mewna.catnip.util
Class JsonUtil
java.lang.Object
com.mewna.catnip.util.JsonUtil
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.grack.nanojson.JsonObject
destringifySnowflakes
(com.grack.nanojson.JsonObject json) Converts all snowflakes in the passed-inJsonObject
from strings to longs.static String
encodePrettily
(com.grack.nanojson.JsonObject data) mapObjectContents
(Function<com.grack.nanojson.JsonObject, T> builder) static com.grack.nanojson.JsonObject
stringifySnowflakes
(com.grack.nanojson.JsonObject json) Converts all snowflakes in the passed-inJsonObject
to strings.static <T> List<T>
stringListToTypedList
(com.grack.nanojson.JsonArray array, Function<String, T> mapper) static <T> List<T>
static <T> List<T>
toListFromCache
(com.grack.nanojson.JsonArray array, Function<String, T> mapper) toMap
(com.grack.nanojson.JsonArray array, Function<com.grack.nanojson.JsonObject, String> keyFunction, Function<com.grack.nanojson.JsonObject, T> mapper) static <T> Set<T>
toMutableSet
(com.grack.nanojson.JsonArray array, Function<com.grack.nanojson.JsonObject, T> mapper) static <T> Set<T>
toSnowflakeList
(com.grack.nanojson.JsonArray array) toStringList
(com.grack.nanojson.JsonArray array) toStringSet
(com.grack.nanojson.JsonArray array)
-
Field Details
-
MAX_SAFE_INTEGER
public static final long MAX_SAFE_INTEGER- See Also:
-
-
Method Details
-
stringifySnowflakes
@Nonnull public static com.grack.nanojson.JsonObject stringifySnowflakes(@Nonnull com.grack.nanojson.JsonObject json) Converts all snowflakes in the passed-inJsonObject
to strings. This method will recursively traverse aJsonObject
, looking for anyidAsLong
keys, and will replace them with stringified versions. This method changes the JSON object that is passed in.- Parameters:
json
- The JSON object to stringify snowflakes in.- Returns:
- The JSON object, with snowflakes longs replaced with strings.
-
destringifySnowflakes
@Nonnull public static com.grack.nanojson.JsonObject destringifySnowflakes(@Nonnull com.grack.nanojson.JsonObject json) Converts all snowflakes in the passed-inJsonObject
from strings to longs. This method will recursively traverse aJsonObject
, looking for anyidAsLong
keys, and will replace them with destringified versions. This method changes the JSON object that is passed in.- Parameters:
json
- The JSON object to destringify snowflakes in.- Returns:
- The JSON object, with snowflakes strings replaced with longs.
-
toList
-
toListFromCache
-
toSet
-
toMutableSet
-
toMap
-
toStringList
-
stringListToTypedList
-
toStringSet
-
toSnowflakeList
-
mapObjectContents
-
encodePrettily
-