1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-25 01:20:34 +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
commit cb5e7532ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View File

@ -142,7 +142,7 @@ dependencies {
exclude module: 'support-annotations' exclude module: 'support-annotations'
}) })
implementation 'com.github.TeamNewPipe:NewPipeExtractor:a5155fb562ca99ca4a9c8caa2fd60f2f0a305eb0' implementation 'com.github.TeamNewPipe:NewPipeExtractor:2780e716b3694ba0f6fe8516847984eadb251f2d'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0' testImplementation 'org.mockito:mockito-core:2.23.0'
@ -162,7 +162,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
// Originally in NewPipeExtractor // Originally in NewPipeExtractor
implementation 'com.grack:nanojson:1.1' implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'org.jsoup:jsoup:1.9.2' implementation 'org.jsoup:jsoup:1.9.2'
implementation 'ch.acra:acra:4.9.2' //4.11 implementation 'ch.acra:acra:4.9.2' //4.11

View File

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

View File

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