1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-11-07 10:43:48 +00:00

Merge pull request #3480 from wb9688/update-nanojson

Use our nanojson fork
This commit is contained in:
Tobias Groza
2020-05-02 16:17:29 +02:00
committed by GitHub
3 changed files with 13 additions and 10 deletions

View File

@@ -74,14 +74,16 @@ public final class ImportExportJsonHelper {
final List<SubscriptionItem> channels = new ArrayList<>();
try {
JsonObject parentObject = JsonParser.object().from(in);
JsonArray channelsArray = parentObject.getArray(JSON_SUBSCRIPTIONS_ARRAY_KEY);
if (eventListener != null) {
eventListener.onSizeReceived(channelsArray.size());
final JsonObject parentObject = JsonParser.object().from(in);
if (!parentObject.has(JSON_SUBSCRIPTIONS_ARRAY_KEY)) {
throw new InvalidSourceException("Channels array is null");
}
if (channelsArray == null) {
throw new InvalidSourceException("Channels array is null");
final JsonArray channelsArray = parentObject.getArray(JSON_SUBSCRIPTIONS_ARRAY_KEY);
if (eventListener != null) {
eventListener.onSizeReceived(channelsArray.size());
}
for (Object o : channelsArray) {

View File

@@ -51,13 +51,14 @@ public final class TabsJsonHelper {
final JsonObject outerJsonObject;
try {
outerJsonObject = JsonParser.object().from(tabsJson);
final JsonArray tabsArray = outerJsonObject.getArray(JSON_TABS_ARRAY_KEY);
if (tabsArray == null) {
if (!outerJsonObject.has(JSON_TABS_ARRAY_KEY)) {
throw new InvalidJsonException("JSON doesn't contain \"" + JSON_TABS_ARRAY_KEY
+ "\" array");
}
final JsonArray tabsArray = outerJsonObject.getArray(JSON_TABS_ARRAY_KEY);
for (Object o : tabsArray) {
if (!(o instanceof JsonObject)) {
continue;