summaryrefslogtreecommitdiff
path: root/compat/json/README.md
blob: 531b87e5e6c8d9dbd16c1b290e78532805e50cd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!--
Copyright (C) 2023  Luke Shumaker <lukeshu@lukeshu.com>

SPDX-License-Identifier: GPL-2.0-or-later
-->

# lowmemjson/compat/json

`lowmemjson/compat/json` is a wrapper around [`lowmemjson`][] that is
a (mostly) drop-in replacement for the standard library's
[`encoding/json`][].

This package does not bother to duplicate `encoding/json`'s
documentation; you should instead refer to [`encoding/json`'s own
documentation][`encoding/json`].

## Incompatibilities

### Tokens

Because the `lowmemjson` parser is fundamentally different than the
`encoding/json` parser and does not have any notion of tokens, the
token API is not included in `lowmemjson/compat/json`:

 - There is no [`Delim`][] type.
 - There is no [`Token`][] type.
 - There is no [`Decoder.Token`][] method.

### Types

When possible, `lowmemjson/compat/json` uses type aliases for the
`encoding/json` types, but in several cases that is not possible
(`Encoder`, `Decoder`, `SyntaxError`, `MarshalError`).  This means
that while `lowmemjson/compat/json` is source-compatible with
`encoding/json`, it may not interoperate with code that also uses
`encoding/json` and relies on those type identities.

The errors returned by the various functions *are* the same errors as
returned by `encoding/json` (with the exception that `SyntaxError` and
`MarshalError` are not type aliases).

### Deprecations

Types that are deprecated in `encoding/json` are not mimiced here:

 - There is no [`InvalidUTF8Error`][] type, as it has been depricated
   since Go 1.2.
 - There is no [`UnmarshalFieldError`][] type, as it has been
   depricated since Go 1.1.

<!-- packages -->
[`lowmemjson`]: https://pkg.go.dev/git.lukeshu.com/go/lowmemjson
[`encoding/json`]: https://pkg.go.dev/encoding/json@go1.20

<!-- symbols -->
[`Delim`]: https://pkg.go.dev/encoding/json@go1.20#Delim
[`Token`]: https://pkg.go.dev/encoding/json@go1.20#Token
[`Decoder.Token`]: https://pkg.go.dev/encoding/json@go1.20#Decoder.Token
[`InvalidUTF8Error`]: https://pkg.go.dev/encoding/json@go1.20#InvalidUTF8Error
[`UnmarshalFieldError`]: https://pkg.go.dev/encoding/json@go1.20#UnmarshalFieldError