1
1
# jsonapi
2
2
3
- [ ![ Build Status] ( https://travis-ci.org/google/jsonapi.svg?branch=master )] ( https://travis-ci.org/google/jsonapi )
4
- [ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/google/jsonapi )] ( https://goreportcard.com/report/github.com/google/jsonapi )
5
- [ ![ GoDoc] ( https://godoc.org/github.com/google/jsonapi?status.svg )] ( http://godoc.org/github.com/google/jsonapi )
6
- [ ![ No Maintenance Intended] ( http://unmaintained.tech/badge.svg )] ( http://unmaintained.tech/ )
3
+ ![ Build Status] ( https://github.com/hashicorp/jsonapi/actions/workflows/ci.yml/badge.svg?main )
4
+ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/hashicorp/jsonapi )
5
+ ![ GoDoc] ( https://godoc.org/github.com/hashicorp/jsonapi?status.svg )
7
6
8
7
A serializer/deserializer for JSON payloads that comply to the
9
- [ JSON API - jsonapi.org] ( http://jsonapi.org ) spec in go.
10
-
8
+ [ JSON API - jsonapi.org] ( http://jsonapi.org ) v1.1 spec in go.
11
9
10
+ This package was forked from [ google/jsonapi] ( https://github.com/google/jsonapi ) and
11
+ adds several enhancements such as [ links] ( #links ) and [ polymorphic relationships] ( #polyrelation ) .
12
12
13
13
## Installation
14
14
15
15
```
16
- go get -u github.com/google /jsonapi
16
+ go get -u github.com/hashicorp /jsonapi
17
17
```
18
18
19
19
Or, see [ Alternative Installation] ( #alternative-installation ) .
@@ -91,9 +91,9 @@ To run,
91
91
* Make sure you have [ Go installed] ( https://golang.org/doc/install )
92
92
* Create the following directories or similar: ` ~/go `
93
93
* Set ` GOPATH ` to ` PWD ` in your shell session, ` export GOPATH=$PWD `
94
- * ` go get github.com/google /jsonapi ` . (Append ` -u ` after ` get ` if you
94
+ * ` go get github.com/hashicorp /jsonapi ` . (Append ` -u ` after ` get ` if you
95
95
are updating.)
96
- * ` cd $GOPATH/src/github.com/google /jsonapi/examples `
96
+ * ` cd $GOPATH/src/github.com/hashicorp /jsonapi/examples `
97
97
* ` go build && ./examples `
98
98
99
99
## ` jsonapi ` Tag Reference
@@ -234,9 +234,6 @@ struct. When accepting input values on this type of choice type, it would a good
234
234
and check that the value is set on only one field.
235
235
236
236
#### ` links `
237
-
238
- * Note: This annotation is an added feature independent of the canonical google/jsonapi package*
239
-
240
237
```
241
238
`jsonapi:"links,omitempty"`
242
239
```
@@ -256,7 +253,7 @@ about the rest?
256
253
### Create Record Example
257
254
258
255
You can Unmarshal a JSON API payload using
259
- [ jsonapi.UnmarshalPayload] ( http://godoc.org/github.com/google /jsonapi#UnmarshalPayload ) .
256
+ [ jsonapi.UnmarshalPayload] ( http://godoc.org/github.com/hashicorp /jsonapi#UnmarshalPayload ) .
260
257
It reads from an [ io.Reader] ( https://golang.org/pkg/io/#Reader )
261
258
containing a JSON API payload for one record (but can have related
262
259
records). Then, it materializes a struct that you created and passed in
@@ -265,7 +262,7 @@ the top level, in request payloads at the moment. Bulk creates and
265
262
updates are not supported yet.
266
263
267
264
After saving your record, you can use,
268
- [ MarshalOnePayload] ( http://godoc.org/github.com/google /jsonapi#MarshalOnePayload ) ,
265
+ [ MarshalOnePayload] ( http://godoc.org/github.com/hashicorp /jsonapi#MarshalOnePayload ) ,
269
266
to write the JSON API response to an
270
267
[ io.Writer] ( https://golang.org/pkg/io/#Writer ) .
271
268
@@ -275,15 +272,15 @@ to write the JSON API response to an
275
272
UnmarshalPayload (in io.Reader , model interface {})
276
273
```
277
274
278
- Visit [ godoc] ( http://godoc.org/github.com/google /jsonapi#UnmarshalPayload )
275
+ Visit [ godoc] ( http://godoc.org/github.com/hashicorp /jsonapi#UnmarshalPayload )
279
276
280
277
#### ` MarshalPayload `
281
278
282
279
``` go
283
280
MarshalPayload (w io.Writer , models interface {}) error
284
281
```
285
282
286
- Visit [ godoc] ( http://godoc.org/github.com/google /jsonapi#MarshalPayload )
283
+ Visit [ godoc] ( http://godoc.org/github.com/hashicorp /jsonapi#MarshalPayload )
287
284
288
285
Writes a JSON API response, with related records sideloaded, into an
289
286
` included ` array. This method encodes a response for either a single record or
@@ -319,7 +316,7 @@ func CreateBlog(w http.ResponseWriter, r *http.Request) {
319
316
UnmarshalManyPayload (in io.Reader , t reflect.Type ) ([]interface {}, error )
320
317
```
321
318
322
- Visit [ godoc] ( http://godoc.org/github.com/google /jsonapi#UnmarshalManyPayload )
319
+ Visit [ godoc] ( http://godoc.org/github.com/hashicorp /jsonapi#UnmarshalManyPayload )
323
320
324
321
Takes an ` io.Reader ` and a ` reflect.Type ` representing the uniform type
325
322
contained within the ` "data" ` JSON API member.
@@ -485,7 +482,7 @@ if err := validate(&myStructToValidate); err != nil {
485
482
MarshalOnePayloadEmbedded (w io.Writer , model interface {}) error
486
483
```
487
484
488
- Visit [ godoc] ( http://godoc.org/github.com/google /jsonapi#MarshalOnePayloadEmbedded )
485
+ Visit [ godoc] ( http://godoc.org/github.com/hashicorp /jsonapi#MarshalOnePayloadEmbedded )
489
486
490
487
This method is not strictly meant to for use in implementation code,
491
488
although feel free. It was mainly created for use in tests; in most cases,
0 commit comments