jsondiff

package module
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2019 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Build Status Coverage Status godoc Go Report Card

go-jsondiff

yet another json diff tool for golang

CLI tool

Install via go get

go get github.com/kamichidu/go-jsondiff/json-diff

Example diff output:

{
    "level": "debug",
    "log": {
        "required": ["hoge", "fuga"],
        "properties": {
            "hoge": {
                "type": "string"
            },
            "fuga": {
                "type": "object",
                "required": ["a", "b"],
                "properties": {
                    "a": {},
                    "b": {}
                }
            }
        }
    },
    "title": "Internal server error",
    "bool": true,
    "float": 0.0,
    "int": 0,
    "eles": [{
        "msg": "a"
    }, {
        "msg": "b"
    }]
}
{
    "level": "info",
    "log": {
        "required": ["fuga", "hoge"],
        "properties": {
            "hoge": {
                "type": "string"
            },
            "fuga": {
                "type": "object",
                "required": ["b", "a"],
                "properties": {
                    "a": {},
                    "b": {}
                }
            }
        }
    },
    "title": "Internal server error\nhello world",
    "bool": false,
    "float": 1.0,
    "int": 1,
    "eles": [{
        "msg": "b"
    }, {
        "msg": "a"
    }, {
        "msg": "c"
    }]
}
> json-diff --set-property '$..required' --set-property '$.eles' a.json b.json
--- "a.json"    2019-03-01 16:29:21.065481500 +0900
+++ "b.json"    2019-03-01 16:48:58.315785000 +0900
@@ $.bool @@
-true
+false

@@ $.eles @@
+{"msg":"c"}

@@ $.float @@
-0.0
+1.0

@@ $.int @@
-0
+1

@@ $.level @@
-"debug"
+"info"

@@ $.title @@
-"Internal server error"
+"Internal server error\nhello world"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hunk

type Hunk struct {
	Path string

	Old, New *[]byte
}

func Diff

func Diff(a, b []byte, opts ...Option) ([]Hunk, error)

type Option

type Option func(*state)

func WithIgnorePath

func WithIgnorePath(v string) Option

func WithLogger

func WithLogger(v *log.Logger) Option

func WithSetPath

func WithSetPath(v string) Option

Directories

Path Synopsis
internal
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址