commit f0ee632f738094c2c92ac3aeb258faf8e797130f Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Sep 11 11:42:10 2018 +0200
Ignore unknown properties when parsing JSON files.
Avoids parse issues with previously deprecated and later removed fields like "as_number" in details documents. --- CHANGELOG.md | 8 ++++++++ src/main/java/org/torproject/onionoo/docs/Document.java | 4 ++++ src/main/java/org/torproject/onionoo/docs/GraphHistory.java | 4 ++++ 3 files changed, 16 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2670f8a..e41f8ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Changes in version 7.0-1.18.1 - 2018-09-11 + + * Medium changes + - Ignore unknown properties when parsing JSON files, which includes + previously deprecated and later removed fields like "as_number" + in details documents. + + # Changes in version 7.0-1.18.0 - 2018-09-10
* Medium changes diff --git a/src/main/java/org/torproject/onionoo/docs/Document.java b/src/main/java/org/torproject/onionoo/docs/Document.java index 9d8d484..ded0d21 100644 --- a/src/main/java/org/torproject/onionoo/docs/Document.java +++ b/src/main/java/org/torproject/onionoo/docs/Document.java @@ -4,6 +4,7 @@ package org.torproject.onionoo.docs;
import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; @@ -18,6 +19,9 @@ import com.fasterxml.jackson.databind.annotation.JsonNaming; getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE) +/* Ignore unknown properties including previously deprecated and later removed + * fields. */ +@JsonIgnoreProperties(ignoreUnknown = true) public abstract class Document {
private transient String documentString; diff --git a/src/main/java/org/torproject/onionoo/docs/GraphHistory.java b/src/main/java/org/torproject/onionoo/docs/GraphHistory.java index 303bae4..b0296e5 100644 --- a/src/main/java/org/torproject/onionoo/docs/GraphHistory.java +++ b/src/main/java/org/torproject/onionoo/docs/GraphHistory.java @@ -4,6 +4,7 @@ package org.torproject.onionoo.docs;
import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; @@ -20,6 +21,9 @@ import java.util.List; getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE) +/* Ignore unknown properties including previously deprecated and later removed + * fields. */ +@JsonIgnoreProperties(ignoreUnknown = true) public class GraphHistory {
private String first;