Documentation
¶
Overview ¶
Command odjson generates reflection-free JSON encoders and decoders for Go struct types.
The generated code implements encoding/json's Marshaler and Unmarshaler and encoding/json/v2's MarshalerTo and UnmarshalerFrom, so an unchanged json.Marshal or json.Unmarshal routes through it. It is bolted onto the standard libraries rather than replacing them: delete the generated file and every call site keeps working, at the library's own speed.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
analyzer
Package analyzer loads Go packages and turns the struct types it finds into the intermediate representation odjson's code generator consumes.
|
Package analyzer loads Go packages and turns the struct types it finds into the intermediate representation odjson's code generator consumes. |
|
codegen
Package codegen turns odjson's intermediate representation into Go source implementing reflection-free JSON encoders and decoders.
|
Package codegen turns odjson's intermediate representation into Go source implementing reflection-free JSON encoders and decoders. |
|
generate
Package generate drives odjson end to end: it analyses a package directory, renders the codec source and writes it back.
|
Package generate drives odjson end to end: it analyses a package directory, renders the codec source and writes it back. |
|
testfixture
Package testfixture holds struct types exercising every field shape the odjson generator supports.
|
Package testfixture holds struct types exercising every field shape the odjson generator supports. |
|
testfixture/crosspkg
Package crosspkg references struct types declared in another package, which odjson encodes through generated helper functions rather than methods.
|
Package crosspkg references struct types declared in another package, which odjson encodes through generated helper functions rather than methods. |
|
testfixture/embed
Package embed exercises encoding/json's field promotion and conflict resolution rules through odjson's generated codecs.
|
Package embed exercises encoding/json's field promotion and conflict resolution rules through odjson's generated codecs. |
|
testfixture/embed/plain
Package plain declares embed's types a second time, with no generated codec attached, so encoding/json's own promotion rules can be observed.
|
Package plain declares embed's types a second time, with no generated codec attached, so encoding/json's own promotion rules can be observed. |
|
testfixture/fallback
Package fallback covers the field shapes odjson cannot generate a direct codec for and therefore hands to encoding/json, plus the types that carry their own JSON representation.
|
Package fallback covers the field shapes odjson cannot generate a direct codec for and therefore hands to encoding/json, plus the types that carry their own JSON representation. |
|
testfixture/other
Package other holds struct types that are referenced from another package but never generated for themselves, so odjson has to emit package level helper functions instead of methods.
|
Package other holds struct types that are referenced from another package but never generated for themselves, so odjson has to emit package level helper functions instead of methods. |
|
testfixture/plain
Package plain declares testfixture's types a second time, with no generated codec attached.
|
Package plain declares testfixture's types a second time, with no generated codec attached. |
|
testfixture/plainref
Package plainref bridges a fixture type to its reflection-only twin.
|
Package plainref bridges a fixture type to its reflection-only twin. |
|
testfixture/suite
Package suite runs the JSON Test Suite through odjson's *generated* decoders, as opposed to odjsonrt's scanner alone.
|
Package suite runs the JSON Test Suite through odjson's *generated* decoders, as opposed to odjsonrt's scanner alone. |
|
testfixture/suite/plain
Package plain declares suite's types a second time, with no generated codec attached, so encoding/json stays the reference the suite is measured against.
|
Package plain declares suite's types a second time, with no generated codec attached, so encoding/json stays the reference the suite is measured against. |
|
testfixture/suitev2
Package suitev2 mirrors package suite, but with the encoding/json/v2 methods generated, so the JSON Test Suite can be run through the jsontext driven decoder and compared against json/v2's own reflection path.
|
Package suitev2 mirrors package suite, but with the encoding/json/v2 methods generated, so the JSON Test Suite can be run through the jsontext driven decoder and compared against json/v2's own reflection path. |
|
testfixture/unexported
Package unexported covers the default type selection, which takes every struct declared in the package, unexported ones included.
|
Package unexported covers the default type selection, which takes every struct declared in the package, unexported ones included. |
|
testfixture/v2parity/gen
Package gen holds the type zoo used to check that odjson's generated encoding/json/v2 methods produce exactly what json/v2's reflection path produces.
|
Package gen holds the type zoo used to check that odjson's generated encoding/json/v2 methods produce exactly what json/v2's reflection path produces. |
|
testfixture/v2parity/plain
Package plain holds the type zoo used to check that odjson's generated encoding/json/v2 methods produce exactly what json/v2's reflection path produces.
|
Package plain holds the type zoo used to check that odjson's generated encoding/json/v2 methods produce exactly what json/v2's reflection path produces. |
|
testfixture/withmethods
Package withmethods exercises the generated MarshalJSON/UnmarshalJSON and encoding/json/v2 methods, which make every JSON library route through odjson's generated codec.
|
Package withmethods exercises the generated MarshalJSON/UnmarshalJSON and encoding/json/v2 methods, which make every JSON library route through odjson's generated codec. |
|
Package odjsonrt provides the low-level runtime helpers that odjson's generated Marshal/Unmarshal code calls into.
|
Package odjsonrt provides the low-level runtime helpers that odjson's generated Marshal/Unmarshal code calls into. |
Click to show internal directories.
Click to hide internal directories.