Documentation
¶
Overview ¶
Author of this file is https://github.com/nsf https://github.com/nsf/jsondiff/blob/master/LICENSE
Index ¶
- Constants
- Variables
- func GZipCompress(input string) ([]byte, error)
- func GZipDecompress(input []byte) ([]byte, error)
- func NewStubborn(conf Config) *client
- type AuthHandler
- type Config
- type DialerFunc
- type Difference
- type DuplexConnector
- type ErrorHandler
- type KeepAlive
- type MessageHandler
- type Options
- type PrintFunc
- type Tag
Constants ¶
const ( TextMessage = 1 BinaryMessage = 2 PingMessage = 9 PongMessage = 10 )
Variables ¶
Functions ¶
func GZipCompress ¶
func GZipDecompress ¶
func NewStubborn ¶
func NewStubborn( conf Config, ) *client
Types ¶
type AuthHandler ¶
type Config ¶
type Config struct {
URL string
IsReconnectable bool
// default message type
MessageType int
// use your favourite logger
Print PrintFunc
// use your favourite client
Dialerf DialerFunc
AuthTimeOut time.Duration
// it is easier to define expected error because exceptions always unexpected :)
UnimportantErrs []error
}
type DialerFunc ¶
type DialerFunc func() (DuplexConnector, error)
type Difference ¶
type Difference int
const ( FullMatch Difference = iota SupersetMatch NoMatch FirstArgIsInvalidJson SecondArgIsInvalidJson BothArgsAreInvalidJson )
func CompareJSON ¶
func CompareJSON(a, b []byte, opts *Options) (Difference, string)
Compares two JSON documents using given options. Returns difference type and a string describing differences.
FullMatch means provided arguments are deeply equal.
SupersetMatch means first argument is a superset of a second argument. In this diffContext being a superset means that for each object or array in the hierarchy which don't match exactly, it must be a superset of another one. For example:
{"a": 123, "b": 456, "c": [7, 8, 9]}
Is a superset of:
{"a": 123, "c": [7, 8]}
NoMatch means there is no match.
The rest of the difference types mean that one of or both JSON documents are invalid JSON.
Returned string uses a format similar to pretty printed JSON to show the human-readable difference between provided JSON documents. It is important to understand that returned format is not a valid JSON and is not meant to be machine readable.
func (Difference) String ¶
func (d Difference) String() string
type DuplexConnector ¶ added in v0.3.0
type ErrorHandler ¶
type ErrorHandler func(err error)
type MessageHandler ¶
type MessageHandler func(resp []byte)
type Options ¶
type Options struct {
Normal Tag
Added Tag
Removed Tag
Changed Tag
Prefix string
Indent string
PrintTypes bool
ChangedSeparator string
}
func DefaultConsoleOptions ¶
func DefaultConsoleOptions() Options
Provides a set of options that are well suited for console output. Options use ANSI foreground color escape sequences to highlight changes.
func DefaultHTMLOptions ¶
func DefaultHTMLOptions() Options
Provides a set of options that are well suited for HTML output. Works best inside <pre> tag.
func DefaultJSONOptions ¶
func DefaultJSONOptions() Options
Provides a set of options in JSON format that are fully parseable.