Class JsonUtils
java.lang.Object
io.github.toberocat.guiengine.utils.JsonUtils
Created: 07.04.2023
- Author:
- Tobias Madlberger (Tobias)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Optional<ParserContext>
getOptionalNode
(@NotNull ParserContext node, @NotNull String field) Get an optional node from the given parent node based on the specified field name.static void
writeArray
(@NotNull GeneratorContext gen, @NotNull String field, int @NotNull [] array) Write an int array into a JSON array field.static void
writeArray
(@NotNull GeneratorContext gen, @NotNull String field, @NotNull Object @NotNull [] array) Write an Object array into a JSON array field.static void
writeArray
(@NotNull GeneratorContext gen, @NotNull String field, @NotNull List<Object> array) Write a List of Objects into a JSON array field.
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
writeArray
public static void writeArray(@NotNull @NotNull GeneratorContext gen, @NotNull @NotNull String field, @NotNull @NotNull Object @NotNull [] array) throws IOException Write an Object array into a JSON array field.- Parameters:
gen
- The generator context to write JSON data.field
- The field name of the JSON array.array
- The Object array to write into the JSON array.- Throws:
IOException
- If an I/O error occurs during the writing process.
-
writeArray
public static void writeArray(@NotNull @NotNull GeneratorContext gen, @NotNull @NotNull String field, int @NotNull [] array) throws IOException Write an int array into a JSON array field.- Parameters:
gen
- The generator context to write JSON data.field
- The field name of the JSON array.array
- The int array to write into the JSON array.- Throws:
IOException
- If an I/O error occurs during the writing process.
-
writeArray
public static void writeArray(@NotNull @NotNull GeneratorContext gen, @NotNull @NotNull String field, @NotNull @NotNull List<Object> array) throws IOException Write a List of Objects into a JSON array field.- Parameters:
gen
- The generator context to write JSON data.field
- The field name of the JSON array.array
- The List of Objects to write into the JSON array.- Throws:
IOException
- If an I/O error occurs during the writing process.
-
getOptionalNode
@NotNull public static @NotNull Optional<ParserContext> getOptionalNode(@NotNull @NotNull ParserContext node, @NotNull @NotNull String field) Get an optional node from the given parent node based on the specified field name.- Parameters:
node
- The parent node to retrieve the optional node from.field
- The field name of the optional node.- Returns:
- An Optional containing the node if found, or an empty Optional if not present.
-