Categorygithub.com/nspcc-dev/go-ordered-json
modulepackage
0.0.0-20240910133904-d2ad7ca8c0c1
Repository: https://github.com/nspcc-dev/go-ordered-json.git
Documentation: pkg.go.dev

# README

.NET-compatible JSON library

It's made for 100% compatibility with the JSON variation used by Neo blockchain. There are three problems there:

  • it's ordered (that's why it's a fork of go-ordered-json)
  • it has different conventions regarding control and "special" symbols
  • it has different conventions wrt incorrect UTF-8

The primary user of this library is NeoGo, it has to be 100% compatible with C# implementation to correctly process transactions, that's why we're maintaining this library and solving any inconsistencies with .NET libraries if found.

If you can, you should avoid using this package. However, if you can't avoid it, then you are welcome to. Provided under the MIT license, just like golang.

# Functions

Compact appends to dst the JSON-encoded src with insignificant space characters elided.
HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029 characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029 so that the JSON will be safe to embed inside HTML <script> tags.
Indent appends to dst an indented form of the JSON-encoded src.
Marshal returns the JSON encoding of v.
MarshalIndent is like Marshal but applies Indent to format the output.
NewDecoder returns a new decoder that reads from r.
NewEncoder returns a new encoder that writes to w.
Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v.
Valid reports whether data is a valid JSON encoding.

# Structs

A Decoder reads and decodes JSON values from an input stream.
An Encoder writes JSON values to an output stream.
An InvalidUnmarshalError describes an invalid argument passed to Unmarshal.
Before Go 1.2, an InvalidUTF8Error was returned by Marshal when attempting to encode a string value with invalid UTF-8 sequences.
No description provided by the author
Member is used to store key/value pairs in an OrderedObject.
A SyntaxError is a description of a JSON syntax error.
An UnmarshalFieldError describes a JSON object key that led to an unexported (and therefore unwritable) struct field.
An UnmarshalTypeError describes a JSON value that was not appropriate for a value of a specific Go type.
An UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.
No description provided by the author

# Interfaces

Marshaler is the interface implemented by types that can marshal themselves into valid JSON.
Unmarshaler is the interface implemented by types that can unmarshal a JSON description of themselves.

# Type aliases

A Delim is a JSON array or object delimiter, one of [ ] { or }.
A Number represents a JSON number literal.
OrderedObject stores the key/value pairs of a JSON object in the order in which they appeared in the original document.
RawMessage is a raw encoded JSON value.
A Token holds a value of one of these types: Delim, for the four JSON delimiters [ ] { } bool, for JSON booleans float64, for JSON numbers Number, for JSON numbers string, for JSON string literals nil, for JSON null.