Skip to content

Commit

Permalink
fix invalid JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed Dec 13, 2022
1 parent a85fe17 commit 88a808f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/main/java/org/grobid/core/data/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,30 @@ public String toJson() {
String outputRawName = new String(encodedRawName);
if (!started) {
started = true;
} else
} else {
json.append(", ");
}
json.append("\"name\" : \"" + outputRawName + "\"");
}

if (getNumeric() != null) {
if (!started) {
started = true;
} else
} else {
json.append(", ");
}
json.append("\"numeric\" : " + getNumeric());
}

if (getStructure() != null) {
if (!started) {
started = true;
} else
} else {
json.append(", ");
json.append("\"structure\" : " + getStructure().toJson() + ", ");
}
json.append("\"structure\" : " + getStructure().toJson());
if (getStructure().getType() != ValueBlock.Type.UNKNOWN) {
json.append(", ");
byte[] encodedParsedName = encoder.quoteAsUTF8(getStructure().toString());
String outputParsedName = new String(encodedParsedName);
json.append("\"parsed\" : \"" + outputParsedName + "\"");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/grobid/core/data/ValueBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ public String toJson() {
String outputRawName = new String(encodedRawName);
if (!started) {
started = true;
} else
} else {
json.append(", ");
}
json.append("\"formatted\" : \"" + outputRawName + "\"");
}

Expand Down

0 comments on commit 88a808f

Please sign in to comment.