Skip to content

Commit

Permalink
prepare additional json serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed Aug 6, 2023
1 parent b06bfd2 commit 4b88b9c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions grobid-core/src/main/java/org/grobid/core/data/Funder.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,25 @@ public String toString() {
builder.append(abbreviatedName);
return builder.toString();
}

public String toJson() {
StringBuilder json = new StringBuilder();
boolean start = false;
json.append("{\n");
if (fullName != null) {
json.append("\t\"fullName\": \"");
json.append(this.fullName + "\"");
start = true;
}
if (abbreviatedName != null) {
if (start)
json.append(",\n");
json.append("\t\"abbreviatedName\": \"");
json.append(this.abbreviatedName + "\"");
}
// to be completed...

json.append("\n}");
return json.toString();
}
}
21 changes: 21 additions & 0 deletions grobid-core/src/main/java/org/grobid/core/data/Funding.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,25 @@ public String toString() {
builder.append("url: " + url.toString() + "\n");
return builder.toString();
}

public String toJson() {
StringBuilder json = new StringBuilder();
boolean start = false;
json.append("{\n");
if (funder != null) {
json.append(funder.toJson());
start = true;
}
if (grantNumber != null) {
if (start)
json.append(",\n");
json.append("\"grantNumber\": \"");
json.append(grantNumber+ "\"");
start = true;
}
// to be completed...

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

0 comments on commit 4b88b9c

Please sign in to comment.