json

package
v0.0.0-...-e03ae22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2018 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DateFormat = "2006-01-02"

Variables

This section is empty.

Functions

func Parse

func Parse(content []byte, data interface{}) error

Types

type Date

type Date time.Time

func (*Date) MarshalJSON

func (dt *Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON

func (dt *Date) UnmarshalJSON(b []byte) error

type Event

type Event struct {
	EventCommon
	Title string `json:"title" validate:"required"`
}

type EventCommon

type EventCommon struct {
	Date     *Date  `json:"date,omitempty"`
	Location string `json:"location,omitempty"`
	Source   string `json:"source,omitempty"`
}
type Header struct {
	Version *int `json:"version" validate:"required,gt=0"`
}

type Names

type Names struct {
	First       string `json:"first,omitempty"`
	Middle      string `json:"middle,omitempty"`
	Last        string `json:"last,omitempty"`
	Alternative string `json:"alternative,omitempty"`
}

type Parents

type Parents struct {
	Father PersonID `json:"father,omitempty"`
	Mother PersonID `json:"mother,omitempty"`
}

type PersonCommon

type PersonCommon struct {
	ID       PersonID `json:"id" validate:"required"`
	Sex      string   `json:"sex" validate:"required,oneof=M F"`
	Comments string   `json:"comments,omitempty"`
}

type PersonID

type PersonID string

type PersonV1

type PersonV1 struct {
	PersonCommon
	FirstName  string `json:"first_name,omitempty"`
	MiddleName string `json:"middle_name,omitempty"`
	LastName   string `json:"last_name,omitempty"`
	Birthday   *Date  `json:"birthday,omitempty"`
	Deathday   *Date  `json:"deathday,omitempty" validate:"omitempty,gtefield=Birthday"`
	Alive      *bool  `json:"alive,omitempty"`
}

type PersonV2

type PersonV2 struct {
	PersonCommon
	Names   *Names       `json:"names" validate:"required"`
	Parents *Parents     `json:"parents,omitempty"`
	Birth   *EventCommon `json:"birth,omitempty"`
	Death   *EventCommon `json:"death,omitempty"`
	Events  *[]Event     `json:"events,omitempty" validate:"omitempty,dive,min=1"`
}

type RelationCommon

type RelationCommon struct {
	Type     string    `json:"type" validate:"required,oneof=wedding civil"`
	Comments string    `json:"comments,omitempty"`
	Person1  *PersonID `json:"person1,omitempty"`
	Person2  *PersonID `json:"person2,omitempty"`
}

type RelationV1

type RelationV1 struct {
	RelationCommon
	Issues *[]PersonID `json:"issues,omitempty" validate:"omitempty,min=1"`
	Begin  *Date       `json:"begin,omitempty"`
	End    *Date       `json:"end,omitempty" validate:"omitempty,gtefield=Begin"`
}

type RelationV2

type RelationV2 struct {
	RelationCommon
	Begin *EventCommon `json:"begin,omitempty"`
	End   *EventCommon `json:"end,omitempty"`
}

type V1

type V1 struct {
	Header
	Comments  string        `json:"comments,omitempty"`
	People    *[]PersonV1   `json:"people" validate:"required,dive,min=1"`
	Relations *[]RelationV1 `json:"relations" validate:"required,dive,min=1"`
}

type V2

type V2 struct {
	Header
	Comments  string        `json:"comments,omitempty"`
	People    *[]PersonV2   `json:"people" validate:"required,dive,min=1"`
	Relations *[]RelationV2 `json:"relations" validate:"required,dive,min=1"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL