Skip to content

Commit

Permalink
Added toString method
Browse files Browse the repository at this point in the history
  • Loading branch information
myMartek committed Feb 22, 2016
1 parent f918345 commit e933e8d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions JsonHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,7 @@ public JsonArray jsonArray() {
return null;
}

public String stringify() {
if (element == null) {
return null;
}

private String stringify() {
Gson gson = new Gson();
return gson.toJson(element);
}
Expand All @@ -275,4 +271,17 @@ public JsonHelperObjectIterator entrySet() {
public Iterator<JsonHelper> iterator() {
return new JsonHelperIterator();
}

@Override
public String toString() {
if (element == null) {
return null;
}

if (element.isJsonPrimitive()) {
return element.getAsJsonPrimitive().getAsString();
}

return stringify();
}
}

0 comments on commit e933e8d

Please sign in to comment.