const x = %*{
"a": [1, 2, 3],
"b": 4,
"c": [5, 6],
"d": {"e": [7, 8], "f": 9}
}
assert len(x, JsonPtr"") == 4
assert contains(x, JsonPtr"/a")
assert kind(x, JsonPtr"/a") == JArray
var y = extract(x, JsonPtr"/d")
# """{"e":[7,8],"f":9}"""
add y, JsonPtr"/e/-", %*[10, 11]
# """{"e":[7,8,[10,11]],"f":9}"""
remove y, JsonPtr"/e/1"
# """{"e":[7,[10,11]],"f":9}"""
Space needed to store JSON is significantly decreased compared to std/json by 1/4. But it takes 3x-4x more space than Araq/packedjson Performance wise, it fits between the two depending on the benchmark. Accessing keys is generally faster than packedjson. But some times splitting really long JsonPtr paths is expensive. More benchmarks are in the repo.
At this point I am unsure if it's worth developing this further. Is this API interface desirable? Do you really need compile-time JSON? Are those time/space/usability tradeoffs acceptable? Feedback really appreciated!
Thanks!
The test operation compares JSON documents.
The problem is that it is currently implemented in both libraries without taking into account that JSON keys are an unordered collection.