Skip to content

Commit

Permalink
Also include unparsed string when converting to JSON object or map.
Browse files Browse the repository at this point in the history
  • Loading branch information
peacekeeper committed May 19, 2021
1 parent c9421eb commit 11eaceb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/foundation/identity/did/DID.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public JsonObject toJsonObject(boolean addParseTree) {
JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder();

jsonObjectBuilder = jsonObjectBuilder
.add("didString", this.getDidString() == null ? JsonValue.NULL : Json.createValue(this.getDidString()))
.add("method", this.getMethod() == null ? JsonValue.NULL : Json.createValue(this.getMethod()))
.add("methodSpecificId", this.getMethodSpecificId() == null ? JsonValue.NULL : Json.createValue(this.getMethodSpecificId()));

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/foundation/identity/did/DIDURL.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public JsonObject toJsonObject(boolean addParseTree) {
JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder();

jsonObjectBuilder = jsonObjectBuilder
.add("didUrlString", this.getDidUrlString() == null ? JsonValue.NULL : Json.createValue(this.getDidUrlString()))
.add("did", this.getDid() == null ? JsonValue.NULL : this.getDid().toJsonObject(addParseTree))
.add("parameters", this.getParameters() == null ? JsonValue.NULL : Json.createObjectBuilder(new HashMap<String, Object>(this.getParameters())).build())
.add("path", this.getPath() == null ? JsonValue.NULL : Json.createValue(this.getPath()))
Expand All @@ -207,6 +208,7 @@ public Map<String, Object> toMap(boolean addParseTree) {

Map<String, Object> map = new HashMap<> ();

map.put("didUrlString", this.getDidUrlString() == null ? null : this.getDidUrlString());
map.put("did", this.getDid() == null ? null : this.getDid().toMap(addParseTree));
map.put("parameters", this.getParameters() == null ? null : new HashMap<String, Object>(this.getParameters()));
map.put("path", this.getPath() == null ? null : this.getPath());
Expand Down

0 comments on commit 11eaceb

Please sign in to comment.