Package net.guizhanss.guizhanlib.utils
Class JsonUtil
java.lang.Object
net.guizhanss.guizhanlib.utils.JsonUtil
Utility methods about json parser.
- Author:
- ybw0014
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.gson.JsonElementgetFromPath(com.google.gson.JsonObject root, String path) The value from given path ofJsonObject.static com.google.gson.JsonElementparse(BufferedReader reader) Parse json fromBufferedReader.static com.google.gson.JsonElementParse jsonString.
-
Constructor Details
-
JsonUtil
public JsonUtil()
-
-
Method Details
-
parse
Parse jsonString.- Parameters:
json- The string to be parsed.- Returns:
- The parsed
JsonElement.
-
parse
Parse json fromBufferedReader.- Parameters:
reader- TheBufferedReaderto read json from.- Returns:
- The parsed
JsonElement.
-
getFromPath
@Nullable public static com.google.gson.JsonElement getFromPath(@Nonnull com.google.gson.JsonObject root, @Nonnull String path) The value from given path ofJsonObject.- Parameters:
root- RootJsonElement.path- The path of target value.- Returns:
- The value got from path,
nullif not found.
-