Class JsonUtils
java.lang.Object
org.schabi.newpipe.extractor.utils.JsonUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.grack.nanojson.JsonArraystatic BooleangetBoolean(com.grack.nanojson.JsonObject object, String path) static com.grack.nanojson.JsonObjectgetJsonData(String html, String variable) Get an attribute of a web page as JSONstatic Numberstatic com.grack.nanojson.JsonObjectstatic StringgetStringListFromJsonArray(com.grack.nanojson.JsonArray array) static Objectstatic com.grack.nanojson.JsonArraytoJsonArray(String responseBody) static com.grack.nanojson.JsonObjecttoJsonObject(String responseBody)
-
Method Details
-
getValue
@Nonnull public static Object getValue(@Nonnull com.grack.nanojson.JsonObject object, @Nonnull String path) throws ParsingException - Throws:
ParsingException
-
getString
@Nonnull public static String getString(@Nonnull com.grack.nanojson.JsonObject object, @Nonnull String path) throws ParsingException - Throws:
ParsingException
-
getBoolean
@Nonnull public static Boolean getBoolean(@Nonnull com.grack.nanojson.JsonObject object, @Nonnull String path) throws ParsingException - Throws:
ParsingException
-
getNumber
@Nonnull public static Number getNumber(@Nonnull com.grack.nanojson.JsonObject object, @Nonnull String path) throws ParsingException - Throws:
ParsingException
-
getObject
@Nonnull public static com.grack.nanojson.JsonObject getObject(@Nonnull com.grack.nanojson.JsonObject object, @Nonnull String path) throws ParsingException - Throws:
ParsingException
-
getArray
@Nonnull public static com.grack.nanojson.JsonArray getArray(@Nonnull com.grack.nanojson.JsonObject object, @Nonnull String path) throws ParsingException - Throws:
ParsingException
-
getValues
@Nonnull public static List<Object> getValues(@Nonnull com.grack.nanojson.JsonArray array, @Nonnull String path) throws ParsingException - Throws:
ParsingException
-
toJsonArray
- Throws:
ParsingException
-
toJsonObject
public static com.grack.nanojson.JsonObject toJsonObject(String responseBody) throws ParsingException - Throws:
ParsingException
-
getJsonData
public static com.grack.nanojson.JsonObject getJsonData(String html, String variable) throws com.grack.nanojson.JsonParserException, ArrayIndexOutOfBoundsException Get an attribute of a web page as JSON
Originally a part of bandcampDirect.
Example HTML:
<p data-town="{"name":"Mycenae","country":"Greece"}"> This is Sparta!</p>Calling this function to get the attribute
data-townreturns the JsonObject for{ "name": "Mycenae", "country": "Greece" }- Parameters:
html- The HTML where the JSON we're looking for is stored inside a variable inside some JavaScript blockvariable- Name of the variable- Returns:
- The JsonObject stored in the variable with this name
- Throws:
com.grack.nanojson.JsonParserExceptionArrayIndexOutOfBoundsException
-
getStringListFromJsonArray
-