Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
gojay
✓ github.com/francoispqt/gojay
Unmarshal JSON into a struct using gojay's object decoding.
package main
import (
"fmt"
"github.com/francoispqt/gojay"
)
type User struct {
Name string
Age int
}
func (u *User) UnmarshalJSONObject(dec *gojay.Decoder, key string) error {
switch key {
case "name":
return dec.String(&u.Name)
case "age":
return dec.Int(&u.Age)
}
return nil
}
func (u *User) NKeys() int { return 2 }
func main() {
u := &User{}
err := gojay.UnmarshalJSONObject([]byte(`{"name":"John","age":30}`), u)
if err != nil {
fmt.Println("Error:", err)
}
fmt.Printf("%+v\n", u)
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
1.2.13latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.