You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
810 B
38 lines
810 B
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
|
|
|
package reqfield
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
func (x X) MarshalJSON() ([]byte, error) {
|
|
type X struct {
|
|
Required int `gencodec:"required"`
|
|
NotRequired int `gencodec:"required" json:"-"`
|
|
}
|
|
var enc X
|
|
enc.Required = x.Required
|
|
enc.NotRequired = x.NotRequired
|
|
return json.Marshal(&enc)
|
|
}
|
|
|
|
func (x *X) UnmarshalJSON(input []byte) error {
|
|
type X struct {
|
|
Required *int `gencodec:"required"`
|
|
NotRequired *int `gencodec:"required" json:"-"`
|
|
}
|
|
var dec X
|
|
if err := json.Unmarshal(input, &dec); err != nil {
|
|
return err
|
|
}
|
|
if dec.Required == nil {
|
|
return errors.New("missing required field 'required' for X")
|
|
}
|
|
x.Required = *dec.Required
|
|
if dec.NotRequired != nil {
|
|
x.NotRequired = *dec.NotRequired
|
|
}
|
|
return nil
|
|
}
|
|
|