Skip to content

Commit

Permalink
avoid NPE when the value is UNKNOWN
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed Dec 12, 2022
1 parent c2b4a34 commit 9d7a7c4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/main/java/org/grobid/core/data/ValueBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,18 @@ public String toJson() {
json.append(", ");


byte[] encodedRawName = encoder.quoteAsUTF8(toString());
String outputRawName = new String(encodedRawName);
if (!started) {
started = true;
} else
json.append(", ");
json.append("\"formatted\" : \"" + outputRawName + "\"");

json.append(" }");
String valueAsString = toString();
if (valueAsString != null) {
byte[] encodedRawName = encoder.quoteAsUTF8(valueAsString);
String outputRawName = new String(encodedRawName);
if (!started) {
started = true;
} else
json.append(", ");
json.append("\"formatted\" : \"" + outputRawName + "\"");

json.append(" }");
}
return json.toString();
}

Expand Down

0 comments on commit 9d7a7c4

Please sign in to comment.