Hello, I want to show you the JSON library I have been developing, and 
hopefully get some feedback. There is a detailed README at 
[planetis-m/packedjson2](https://github.com/planetis-m/packedjson2) and the 
state is still alpha. The biggest feature is that it implements the [JSON 
Patch](https://jsonpatch.com/) RFC. Or at least it will be once `replace`, 
`move` and `copy` are added. Implementation consists of a list of nodes and a 
biderectional hashtable and uses less memory than std/json. A nice bonus is 
that it works at compile-time, since instead of working with references like 
`JsonNode`, I have switched the approach to using a `JsonPtr` to specify a 
path. 

# Example
    
    
    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}"""
    
    Run

# Performance

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](https://github.com/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.

# Feedback needed

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!

Reply via email to