TinyJSON is a codegen for JSONMarshal & JSONUnmarshal methods. It uses go/ast
to parse structs in packages, so any code won't run inside repo.
It targets to support tinygo and avoid interfaces and reflect calls to aim
the best speed and tiny size.
Lexer is built using ragel, which produces pushdown automaton.
Theoretically it is the fastest possible lexer for json.
It is in alpha. Almost everything works. Interfaces not supported yet. Feel free to file issue.
go get github.com/rgnu/tinyjson
go install github.com/rgnu/tinyjsonadd this comment somewhere in library
//go:generate tinyjson $GOFILEand this before each structure you want to have JSONMarshal & JSONUnmarshal methods.
//tinyjson:jsonWarning: the comment above is only visible inside batch structure declaration. (TODO: fix)
Then run go generate in package dir.
The goal is to depend only on bytes, strconv and tiny repo lexer with errors, strconv dependency.
"bytes"
"strconv"
"github.com/tinyjson/lexer"
All most everything is working. Interfaces not supported yet. Pointers could not work sometimes (e.g. pointers on pointers and so on).
- Add support for all kind of pointers.
- Add support for optional marshal and unmarshal methods building.
- Add sting constant optimisation for marshalers.
- Add optional support for interfaces.
