Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Nov 15, 2023
1 parent 360ddf0 commit 4d8a31f
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# jsonapi

[![Build Status](https://travis-ci.org/google/jsonapi.svg?branch=master)](https://travis-ci.org/google/jsonapi)
[![Go Report Card](https://goreportcard.com/badge/github.com/google/jsonapi)](https://goreportcard.com/report/github.com/google/jsonapi)
[![GoDoc](https://godoc.org/github.com/google/jsonapi?status.svg)](http://godoc.org/github.com/google/jsonapi)
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
![Build Status](https://github.com/hashicorp/jsonapi/actions/workflows/ci.yml/badge.svg?main)
![Go Report Card](https://goreportcard.com/badge/github.com/hashicorp/jsonapi)
![GoDoc](https://godoc.org/github.com/hashicorp/jsonapi?status.svg)

A serializer/deserializer for JSON payloads that comply to the
[JSON API - jsonapi.org](http://jsonapi.org) spec in go.

[JSON API - jsonapi.org](http://jsonapi.org) v1.1 spec in go.

This package was forked from [google/jsonapi](https://github.com/google/jsonapi) and
adds several enhancements such as [links](#links) and [polymorphic relationships](#polyrelation).

## Installation

```
go get -u github.com/google/jsonapi
go get -u github.com/hashicorp/jsonapi
```

Or, see [Alternative Installation](#alternative-installation).
Expand Down Expand Up @@ -91,9 +91,9 @@ To run,
* Make sure you have [Go installed](https://golang.org/doc/install)
* Create the following directories or similar: `~/go`
* Set `GOPATH` to `PWD` in your shell session, `export GOPATH=$PWD`
* `go get github.com/google/jsonapi`. (Append `-u` after `get` if you
* `go get github.com/hashicorp/jsonapi`. (Append `-u` after `get` if you
are updating.)
* `cd $GOPATH/src/github.com/google/jsonapi/examples`
* `cd $GOPATH/src/github.com/hashicorp/jsonapi/examples`
* `go build && ./examples`

## `jsonapi` Tag Reference
Expand Down Expand Up @@ -234,9 +234,6 @@ struct. When accepting input values on this type of choice type, it would a good
and check that the value is set on only one field.

#### `links`

*Note: This annotation is an added feature independent of the canonical google/jsonapi package*

```
`jsonapi:"links,omitempty"`
```
Expand All @@ -256,7 +253,7 @@ about the rest?
### Create Record Example

You can Unmarshal a JSON API payload using
[jsonapi.UnmarshalPayload](http://godoc.org/github.com/google/jsonapi#UnmarshalPayload).
[jsonapi.UnmarshalPayload](http://godoc.org/github.com/hashicorp/jsonapi#UnmarshalPayload).
It reads from an [io.Reader](https://golang.org/pkg/io/#Reader)
containing a JSON API payload for one record (but can have related
records). Then, it materializes a struct that you created and passed in
Expand All @@ -265,7 +262,7 @@ the top level, in request payloads at the moment. Bulk creates and
updates are not supported yet.

After saving your record, you can use,
[MarshalOnePayload](http://godoc.org/github.com/google/jsonapi#MarshalOnePayload),
[MarshalOnePayload](http://godoc.org/github.com/hashicorp/jsonapi#MarshalOnePayload),
to write the JSON API response to an
[io.Writer](https://golang.org/pkg/io/#Writer).

Expand All @@ -275,15 +272,15 @@ to write the JSON API response to an
UnmarshalPayload(in io.Reader, model interface{})
```

Visit [godoc](http://godoc.org/github.com/google/jsonapi#UnmarshalPayload)
Visit [godoc](http://godoc.org/github.com/hashicorp/jsonapi#UnmarshalPayload)

#### `MarshalPayload`

```go
MarshalPayload(w io.Writer, models interface{}) error
```

Visit [godoc](http://godoc.org/github.com/google/jsonapi#MarshalPayload)
Visit [godoc](http://godoc.org/github.com/hashicorp/jsonapi#MarshalPayload)

Writes a JSON API response, with related records sideloaded, into an
`included` array. This method encodes a response for either a single record or
Expand Down Expand Up @@ -319,7 +316,7 @@ func CreateBlog(w http.ResponseWriter, r *http.Request) {
UnmarshalManyPayload(in io.Reader, t reflect.Type) ([]interface{}, error)
```

Visit [godoc](http://godoc.org/github.com/google/jsonapi#UnmarshalManyPayload)
Visit [godoc](http://godoc.org/github.com/hashicorp/jsonapi#UnmarshalManyPayload)

Takes an `io.Reader` and a `reflect.Type` representing the uniform type
contained within the `"data"` JSON API member.
Expand Down Expand Up @@ -485,7 +482,7 @@ if err := validate(&myStructToValidate); err != nil {
MarshalOnePayloadEmbedded(w io.Writer, model interface{}) error
```

Visit [godoc](http://godoc.org/github.com/google/jsonapi#MarshalOnePayloadEmbedded)
Visit [godoc](http://godoc.org/github.com/hashicorp/jsonapi#MarshalOnePayloadEmbedded)

This method is not strictly meant to for use in implementation code,
although feel free. It was mainly created for use in tests; in most cases,
Expand Down

0 comments on commit 4d8a31f

Please sign in to comment.