package
0.0.0-20180327163337-f8253d0d8d32
Repository: https://github.com/picatic/api2go.git
Documentation: pkg.go.dev

# README

api2go JSONAPI package

This package contains JSON API compatible marshal und unmarshal functionality.

  go get github.com/manyminds/api2go/jsonapi

Usage

For information on how to use this package, please refer to the documentation on the api2go main project, the integration_test.go or the godoc.

# Functions

Dejsonify returns a go struct key name from a JSON key name.
GetTagValueByName returns one api2go setting.
Jsonify returns a JSON formatted key name from a go struct field name.
Marshal thats the input from `data` which can be a struct, a slice, or a pointer of it.
MarshalToJSON marshals a struct to json it works like `Marshal` but returns json instead.
MarshalToJSONWithURLs marshals a struct to json with URLs in `links`.
MarshalWithURLs can be used to include the generation of `related` and `self` links.
Pluralize a noun.
Singularize a noun.
Unmarshal reads a JSONAPI map to a model struct target must at least implement the `UnmarshalIdentifier` interface.
UnmarshalFromJSON reads a JSONAPI compatible JSON document to a model struct target must be a struct or a slice of it.
UnmarshalInto reads input params for one struct from `input` and marshals it into `targetSliceVal`, which may be a slice of targetStructType or a slice of pointers to targetStructType.
UnmarshalRelationshipsData is used by api2go.API to only unmarshal references inside a data object.

# Structs

Reference information about possible references of a struct If IsNotLoaded is set to true, the `data` field will be omitted and only the `links` object will be generated.
ReferenceID contains all necessary information in order to reference another struct in jsonapi.

# Interfaces

The EditToManyRelations interface can be optionally implemented to add and delete to-many relationships on a already unmarshalled struct.
The EntityNamer interface can be opionally implemented to rename a struct.
MarshalIdentifier interface is necessary to give an element a unique ID.
MarshalIncludedRelations must be implemented if referenced structs should be included.
MarshalLinkedRelations must be implemented if there are references and the reference IDs should be included.
MarshalReferences must be implemented if the struct to be serialized has relations.
ServerInformation can be passed to MarshalWithURLs to generate the `self` and `related` urls inside `links`.
UnmarshalIdentifier interface to set ID when unmarshalling.
UnmarshalToManyRelations must be implemented to unmarshal to-many relations.
UnmarshalToOneRelations must be implemented to unmarshal to-one relations.