Documentation ¶
Overview ¶
Package gojsondiff implements "Diff" that compares two JSON objects and generates Deltas that describes differences between them. The package also provides "Patch" that apply Deltas to a JSON object.
Index ¶
- type Added
- type Array
- type Deleted
- type Delta
- type Diff
- type Differ
- type Index
- type Modified
- type Moved
- type Name
- type Object
- type Position
- type PostDelta
- type PreDelta
- type TextDiff
- type Unmarshaller
- func (um *Unmarshaller) UnmarshalBytes(diffBytes []byte) (Diff, error)
- func (um *Unmarshaller) UnmarshalObject(diffObj map[string]interface{}) (Diff, error)
- func (um *Unmarshaller) UnmarshalReader(diffReader io.Reader) (Diff, error)
- func (um *Unmarshaller) UnmarshalString(diffString string) (Diff, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Added ¶
type Added struct { // Values holds the added value Value interface{} // contains filtered or unexported fields }
An Added represents a new added field of an object or an array
func (Added) PostPosition ¶
func (i Added) PostPosition() Position
func (Added) Similarity ¶
func (cache Added) Similarity() (similarity float64)
type Array ¶
type Array struct { // Deltas holds internal Deltas Deltas []Delta // contains filtered or unexported fields }
An Array is a Delta that represents an array of JSON
func (Array) PostPosition ¶
func (i Array) PostPosition() Position
func (Array) Similarity ¶
func (cache Array) Similarity() (similarity float64)
type Deleted ¶
type Deleted struct { // The value deleted Value interface{} // contains filtered or unexported fields }
A Delted represents deleted field or index of an Object or an Array.
func NewDeleted ¶
NewDeleted returns a Deleted
func (Deleted) PrePosition ¶
func (i Deleted) PrePosition() Position
func (Deleted) Similarity ¶
type Delta ¶
type Delta interface { // Similarity calculates the similarity of the Delta values. // The return value is normalized from 0 to 1, // 0 is completely different and 1 is they are same Similarity() (similarity float64) }
A Delta represents an atomic difference between two JSON objects.
type Diff ¶
type Diff interface { // Deltas returns Deltas that describe differences between two JSON objects Deltas() []Delta // Modified returnes true if Diff has at least one Delta. Modified() bool }
A Diff holds deltas generated by a Differ
type Differ ¶
type Differ struct {
// contains filtered or unexported fields
}
A Differ conmapres JSON objects and apply patches
func (*Differ) ApplyPatch ¶
ApplyPatch applies a Diff to an JSON object. This method is destructive.
type Index ¶
type Index int
A Index is a Position with an int value, which means the Delta is in an Array.
type Modified ¶
type Modified struct { // The value before modification OldValue interface{} // The value after modification NewValue interface{} // contains filtered or unexported fields }
A Modified represents a field whose value is changed.
func NewModified ¶
NewModified returns a Modified
func (Modified) PostPosition ¶
func (i Modified) PostPosition() Position
func (Modified) Similarity ¶
func (cache Modified) Similarity() (similarity float64)
type Moved ¶
type Moved struct { // The value before moving Value interface{} // The delta applied after moving (for compatibility) Delta interface{} // contains filtered or unexported fields }
A Moved represents field that is moved, which means the index or name is changed. Note that, in this library, assigning a Moved and a Modified to a single position is not allowed. For the compatibility with jsondiffpatch, the Moved in this library can hold the old and new value in it.
func (Moved) PostPosition ¶
func (i Moved) PostPosition() Position
func (Moved) PrePosition ¶
func (i Moved) PrePosition() Position
func (Moved) Similarity ¶
func (cache Moved) Similarity() (similarity float64)
type Name ¶
type Name string
A Name is a Postition with a string, which means the delta is in an object.
type Object ¶
type Object struct { // Deltas holds internal Deltas Deltas []Delta // contains filtered or unexported fields }
An Object is a Delta that represents an object of JSON
func (Object) PostPosition ¶
func (i Object) PostPosition() Position
func (Object) Similarity ¶
func (cache Object) Similarity() (similarity float64)
type Position ¶
type Position interface { // String returns the position as a string String() (name string) // CompareTo returns a true if the Position is smaller than another Position. // This function is used to sort Positions by the sort package. CompareTo(another Position) bool }
A Position represents the position of a Delta in an object or an array.
type PostDelta ¶
type PostDelta interface { // PostPosition returns the Position. PostPosition() Position // PostApply applies the delta to object. PostApply(object interface{}) interface{} }
A PreDelta is a Delta that has a position of the right side JSON object. Deltas implements this interface should be applies after PreDeltas.
type PreDelta ¶
type PreDelta interface { // PrePosition returns the Position. PrePosition() Position // PreApply applies the delta to object. PreApply(object interface{}) interface{} }
A PreDelta is a Delta that has a position of the left side JSON object. Deltas implements this interface should be applies before PostDeltas.
type TextDiff ¶
A TextDiff represents a Modified with TextDiff between the old and the new values.
func NewTextDiff ¶
NewTextDiff returns
func (*TextDiff) DiffString ¶
func (TextDiff) PostPosition ¶
func (i TextDiff) PostPosition() Position
func (TextDiff) Similarity ¶
func (cache TextDiff) Similarity() (similarity float64)
type Unmarshaller ¶
type Unmarshaller struct { }
func NewUnmarshaller ¶
func NewUnmarshaller() *Unmarshaller
func (*Unmarshaller) UnmarshalBytes ¶
func (um *Unmarshaller) UnmarshalBytes(diffBytes []byte) (Diff, error)
func (*Unmarshaller) UnmarshalObject ¶
func (um *Unmarshaller) UnmarshalObject(diffObj map[string]interface{}) (Diff, error)
func (*Unmarshaller) UnmarshalReader ¶
func (um *Unmarshaller) UnmarshalReader(diffReader io.Reader) (Diff, error)
func (*Unmarshaller) UnmarshalString ¶
func (um *Unmarshaller) UnmarshalString(diffString string) (Diff, error)
Directories ¶
Path | Synopsis |
---|---|
Godeps
|
|
_workspace/src/github.com/codegangsta/cli
Package cli provides a minimal framework for creating and organizing command line Go applications.
|
Package cli provides a minimal framework for creating and organizing command line Go applications. |
_workspace/src/github.com/onsi/ginkgo
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
|
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API. |
_workspace/src/github.com/onsi/ginkgo/config
Ginkgo accepts a number of configuration options.
|
Ginkgo accepts a number of configuration options. |
_workspace/src/github.com/onsi/ginkgo/ginkgo
The Ginkgo CLI The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) You can also learn more by running: ginkgo help Here are some of the more commonly used commands: To install: go install github.com/onsi/ginkgo/ginkgo To run tests: ginkgo To run tests in all subdirectories: ginkgo -r To run tests in particular packages: ginkgo <flags> /path/to/package /path/to/another/package To pass arguments/flags to your tests: ginkgo <flags> <packages> -- <pass-throughs> To run tests in parallel ginkgo -p this will automatically detect the optimal number of nodes to use.
|
The Ginkgo CLI The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) You can also learn more by running: ginkgo help Here are some of the more commonly used commands: To install: go install github.com/onsi/ginkgo/ginkgo To run tests: ginkgo To run tests in all subdirectories: ginkgo -r To run tests in particular packages: ginkgo <flags> /path/to/package /path/to/another/package To pass arguments/flags to your tests: ginkgo <flags> <packages> -- <pass-throughs> To run tests in parallel ginkgo -p this will automatically detect the optimal number of nodes to use. |
_workspace/src/github.com/onsi/ginkgo/internal/remote
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output coherently as tests complete.
|
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output coherently as tests complete. |
_workspace/src/github.com/onsi/ginkgo/reporters
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
|
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output. |
_workspace/src/github.com/onsi/gomega
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
|
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library. |
_workspace/src/github.com/onsi/gomega/format
Gomega's format package pretty-prints objects.
|
Gomega's format package pretty-prints objects. |
_workspace/src/github.com/onsi/gomega/gbytes
Package gbytes provides a buffer that supports incrementally detecting input.
|
Package gbytes provides a buffer that supports incrementally detecting input. |
_workspace/src/github.com/onsi/gomega/gexec
Package gexec provides support for testing external processes.
|
Package gexec provides support for testing external processes. |
_workspace/src/github.com/onsi/gomega/ghttp
Package ghttp supports testing HTTP clients by providing a test server (simply a thin wrapper around httptest's server) that supports registering multiple handlers.
|
Package ghttp supports testing HTTP clients by providing a test server (simply a thin wrapper around httptest's server) that supports registering multiple handlers. |
_workspace/src/github.com/onsi/gomega/matchers
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.
|
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported. |
_workspace/src/github.com/sergi/go-diff/diffmatchpatch
Package diffmatchpatch offers robust algorithms to perform the operations required for synchronizing plain text.
|
Package diffmatchpatch offers robust algorithms to perform the operations required for synchronizing plain text. |