# README
Fork of the golang "json" package because of "bulk template" parsing requirements (see notelib/bulk.go), with the base being Go 1.12 src/encoding/json http://golang.org/dl/go1.12.src.tar.gz
-
Because we need to decompose and reconstruct the JSON template in a linear manner, we need to parse it and reconstruct it with its delimiters in-place. Unfortunately, the standard JSON Decoder suppresses commas and colons and quotes. And so jsonxt returns all delimiters, not just []{}
-
Because we are serializing the values without serializing the keys, we need to know in the Decoder when the string it is sending us is a key vs a value. And so we changed it (in a hacky way) to return keys as "quoted" strings, and values as standard unquoted strings.
$ diff stream.go ~/desktop/go1-12/src/encoding/json
1,4d0
< // NOTE that this is a copy of https://golang.org/src/encoding/json/stream.go with the only changes being:
< // 1) Token() always returns the next token, not just []{}. The XT prefix means "extended token".
< // 2) For string literals that are KEYS, it returns it "quoted" so we can know it's a field, not a value
< //
9c5
< package jsonxt
---
> package json
419,420c415
< // continue
< return Delim(':'), nil
---
> continue
426,427c421
< // continue
< return Delim(','), nil
---
> continue
432,433c426
< // continue
< return Delim(','), nil
---
> continue
448,449c441
< // return x, nil
< return "\"" + x + "\"", nil
---
> return x, nil
# 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.
InvalidUTF8Error (golint) Before Go 1.2, an InvalidUTF8Error was returned by Marshal when attempting to encode a string value with invalid UTF-8 sequences.
A MarshalerError represents an error from calling a MarshalJSON or MarshalText method.
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.
An UnsupportedValueError is returned by Marshal when attempting.
# Interfaces
Marshaler is the interface implemented by types that can marshal themselves into valid JSON.
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
.
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.
RawMessage is a raw encoded JSON value.