| 1 |
## JSON Canonicalizer for Go |
| 2 |
|
| 3 |
The [jsoncanonicalizer](src/webpki.org/jsoncanonicalizer) |
| 4 |
folder contains the source code for a |
| 5 |
JCS (RFC 8785) compliant JSON canonicalizer written in Go. |
| 6 |
|
| 7 |
### Building and testing |
| 8 |
|
| 9 |
- Set GOPATH to this directory. |
| 10 |
|
| 11 |
- For running `verify-numbers.go` you need to download a 3Gb+ file with test |
| 12 |
data described in the root directory [testdata](../testdata). This file can be stored in |
| 13 |
any directory and requires updating the file path in `verify-numbers.go`. |
| 14 |
|
| 15 |
- Perform the commands: |
| 16 |
```code |
| 17 |
$ cd test |
| 18 |
$ go build webpki.org/jsoncanonicalizer |
| 19 |
$ go run verify-canonicalization.go |
| 20 |
$ go run verify-numbers.go |
| 21 |
``` |
| 22 |
|
| 23 |
|
| 24 |
### Using the JSON canonicalizer |
| 25 |
|
| 26 |
```go |
| 27 |
import "webpki.org/jsoncanonicalizer" |
| 28 |
|
| 29 |
func Transform(jsonData []byte) (result []byte, e error) |
| 30 |
``` |
| 31 |
Note that both the input and the result is assumed to be in UTF-8 format. |
| 32 |
|
| 33 |
### Constraints |
| 34 |
The JSON canonicalizer only accepts a JSON _Object_ or _Array_ as the top level data type. |