Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads input in JPV format and streams it into a JSON stream.
JPV is a format that can represent values where each line specifies a leaf value and its path. A Lines are separated by '\n' and are of the form
<path> = <value>
where <path> is a JSONPath and <value> is a JSON value. E.g.
{"name": "Dan", "parent_ids": [132, 7650]}
is represented as
$.["name"] = "Dan" $.["parent_ids"][0] = 132 $.["parent_ids"][1] = 7650
The potential value in this format is that it can be piped through grep and other unix utilites to be filtered / transformed, then turned back into JSON.
func NewDecoder ¶
NewDecoder sets up a new Decoder instance to read from the given input.
type Encoder ¶
type Encoder struct {
format.Printer
*format.Colorizer
AlwaysQuoteKeys bool
// contains filtered or unexported fields
}
A Encoder can output a stream encoding a JSON value using the given Printer instance for formatting. It prints the JSON value in the JPV format (see Decoder for details of the format).
func (*Encoder) Consume ¶
Consume formats the JSON stream encoded in the given channel using the instance's Printer. It assumes that the stream is well-formed, i.e. is a valid encoding for a stream of JSON values and may panic if that is not the case.
And error can be returned if the Printer could not perform some writing operation. A typical example is if it attempt to write to a closed pipe.