Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Apr 3, 2024
1 parent 4756200 commit 224d9c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ assert $extract(x, JsonPtr"/d") == """{"e":[7],"f":"foo"}"""
assert fromJson(x, JsonPtr"/a/3", seq[int]) == @[5, 6]
assert toJson(@[5, 6]) == extract(x, JsonPtr"/b")
# Iterating
for x in items(x, JsonPtr"/b", int): echo x, " "
for i in items(x, JsonPtr"/b", int): echo i, " "
# 5 6
for k, v in pairs(x, JsonPtr"/d", JsonTree): echo (k, v), " "
# ("e", [7]) ("f", "foo")
Expand All @@ -195,7 +195,7 @@ for k, v in pairs(x, JsonPtr"/d", JsonTree): echo (k, v), " "
This section details the average time (in milliseconds) it takes to perform
various operations on a JSON document containing 1,000 entries.

| Op \ Lib | jsonpak | std/json |
| Op\Lib | jsonpak | std/json |
|----------|----------|----------|
| Extract | 0.2805 | 0.7552 |
| toString | 0.8243 | 0.6683 |
Expand Down
2 changes: 1 addition & 1 deletion src/jsonpak/builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ proc initFromJson*[T: object|tuple](dst: var T; tree: JsonTree; n: NodePos) =
for k, v in dst.fieldPairs:
if x.str == k:
initFromJson(v, tree, x.firstSon)
break
break # emulate elif

proc fromJson*[T](tree: JsonTree; path: JsonPtr; t: typedesc[T]): T =
let n = findNode(tree, path.string)
Expand Down
2 changes: 1 addition & 1 deletion tests/texample.nim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ assert $extract(x, JsonPtr"/d") == """{"e":[7],"f":"foo"}"""
assert fromJson(x, JsonPtr"/a/3", seq[int]) == @[5, 6]
assert toJson(@[5, 6]) == extract(x, JsonPtr"/b")
# Iterating
for x in items(x, JsonPtr"/b", int): echo x, " "
for i in items(x, JsonPtr"/b", int): echo i, " "
# 5 6
for k, v in pairs(x, JsonPtr"/d", JsonTree): echo (k, v), " "
# ("e", [7]) ("f", "foo")

0 comments on commit 224d9c5

Please sign in to comment.