Skip to content

Commit d845a3f

Browse files
committed
Fix for size information at merkle node.
1 parent 6486fff commit d845a3f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/java/io/ipfs/api/MerkleNode.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ public static MerkleNode fromJSON(Object rawjson) {
8484
}
8585

8686
public Object toJSON() {
87-
Map res = new TreeMap<>();
87+
Map<String, Object> res = new TreeMap<>();
8888
res.put("Hash", hash);
8989
res.put("Links", links.stream().map(x -> x.hash).collect(Collectors.toList()));
90-
if (data.isPresent())
91-
res.put("Data", data.get());
92-
if (name.isPresent())
93-
res.put("Name", name.get());
94-
if (size.isPresent())
95-
res.put("Size", size.isPresent() ? size.get() : largeSize.get());
96-
if (type.isPresent())
97-
res.put("Type", type.get());
90+
data.ifPresent(bytes -> res.put("Data", bytes));
91+
name.ifPresent(s -> res.put("Name", s));
92+
if (size.isPresent()) {
93+
res.put("Size", size.get());
94+
} else {
95+
largeSize.ifPresent(s -> res.put("Size", s));
96+
}
97+
type.ifPresent(integer -> res.put("Type", integer));
9898
return res;
9999
}
100100

0 commit comments

Comments
 (0)