Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Jan 24, 2024
1 parent fa793cd commit e47ca10
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ var opts = sonic.SearchOptions{
val, err := opts.GetFromString(json, paths...) // skip and search JSON
any, err := val.Interface() // converts to go primitive type
```
Besides thread-safty, the main difference between `Value` and `Node` is that `Value` is implemented by pure `search-and-skip` of raw JSON, which means:
- When visit a path for the first time, `Value` only need to search entire JSON and return a node located by path, no need to parse and deserialize on-the-way nodes. In this case, it is faster than `Node`.
- When visit a repeated path more than once, `Value` still need to search the entire JSON and return the node, not like `Node` who can derefer and skip on-the-way nodes. In this case, it is slower than `Node`.
In one word, if your application **visit each JSON path exacly once**, without much overlapping, we advice you to use `Value`. Otherwise you'd better use `Node`

#### APIs
Most of its APIs are same with `ast.Node`'s, including both `Get` and `Set`. Besides:
Expand Down

0 comments on commit e47ca10

Please sign in to comment.