You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fork from buger/jsonparser: rename module, apply security fixes and enhancements
Module renamed from github.com/buger/jsonparser to github.com/securityguy/jsonparser.
Security fixes:
- Fix GO-2026-4514: Delete() panics on malformed JSON (negative slice index DoS)
- Update Dockerfile base image from golang:1.6 to golang:1.21
Bug fixes:
- Fix EachKey failing to extract values from arrays of strings (PR buger#180)
- Remove duplicate import in parser_test.go (PR buger#263)
New APIs (all additive):
- ArrayEach callback now accepts *error for early termination; DoneError sentinel added (PR buger#134)
- DeleteOnOrig: in-place deletion variant with no allocation (PR buger#256)
- ArrayIterator: lazy closure-based array iteration (PR buger#254)
- GetRaw, EachRawKey: raw JSON byte extraction without type parsing (PR buger#250)
Other:
- go.mod bumped to go 1.18
- benchmark/go.mod updated with replace directive pointing to local module
- CLAUDE.md added for Claude Code guidance
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-`bytes.go` — Custom integer/float parsing (~2x faster than `strconv` for JSON numbers)
33
+
-`bytes_unsafe.go` / `bytes_safe.go` — Platform-specific byte↔string conversions; `bytes_unsafe.go` is used by default (build tag `!appengine`), `bytes_safe.go` for AppEngine (`appengine` tag)
34
+
35
+
### Key Design Principles
36
+
37
+
-**Zero allocation**: The parser avoids heap allocations on hot paths. Avoid changes that introduce allocations in `Get`, `ArrayEach`, `ObjectEach`, or `EachKey`.
38
+
-**No schema**: Returns `[]byte` slices into the original data; callers convert types via helpers like `GetString`, `GetInt`, `GetFloat`.
39
+
-**`EachKey` is the fastest multi-path API**: It scans the JSON once for multiple keys simultaneously.
40
+
41
+
### Value Types
42
+
43
+
```go
44
+
const (
45
+
NotExistValueType = iota
46
+
String
47
+
Number
48
+
Object
49
+
Array
50
+
Boolean
51
+
Null
52
+
Unknown
53
+
)
54
+
```
55
+
56
+
### Benchmarks
57
+
58
+
The `benchmark/` directory has its own `go.mod` and compares against ffjson, easyjson, and codecgen. Run separately with `cd benchmark && go test -bench=.`.
# Alternative JSON parser for Go (10x times faster standard library)
3
3
4
-
**This library was forked from buger/jsonparser on March 18, 2026.**
4
+
**This library is a fork of [buger/jsonparser](https://github.com/buger/jsonparser), maintained at github.com/securityguy/jsonparser.**
5
5
6
6
It does not require you to know the structure of the payload (eg. create structs), and allows accessing fields by providing the path to them. It is up to **10 times faster** than standard `encoding/json` package (depending on payload size and usage), **allocates no memory**. See benchmarks below.
7
7
@@ -17,7 +17,7 @@ Goal of this project is to push JSON parser to the performance limits and not sa
17
17
For the given JSON our goal is to extract the user's full name, number of github followers and avatar.
18
18
19
19
```go
20
-
import"github.com/buger/jsonparser"
20
+
import"github.com/securityguy/jsonparser"
21
21
22
22
...
23
23
@@ -96,7 +96,7 @@ jsonparser.EachKey(data, func(idx int, value []byte, vt jsonparser.ValueType, er
96
96
97
97
Library API is really simple. You just need the `Get` method to perform any operation. The rest is just helpers around it.
98
98
99
-
You also can view API at [godoc.org](https://godoc.org/github.com/buger/jsonparser)
99
+
You also can view API at [pkg.go.dev](https://pkg.go.dev/github.com/securityguy/jsonparser)
100
100
101
101
102
102
### **`Get`**
@@ -250,7 +250,7 @@ Compared libraries:
250
250
* https://github.com/ugorji/go/codec
251
251
* https://github.com/pquerna/ffjson
252
252
* https://github.com/mailru/easyjson
253
-
* https://github.com/buger/jsonparser
253
+
* https://github.com/securityguy/jsonparser
254
254
255
255
#### TLDR
256
256
If you want to skip next sections we have 2 winner: `jsonparser` and `easyjson`.
@@ -270,7 +270,7 @@ With great power comes great responsibility! :)
270
270
271
271
Each test processes 190 bytes of http log as a JSON record.
0 commit comments