jsondiff

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package jsondiff ...

Index

Constants

View Source
const (
	IgnorePath        = Strategy(1 << 0) // 忽略匹配路径
	IgnoreValue       = Strategy(1 << 1) // 忽略路径的值
	IgnoreArrayOrder  = Strategy(1 << 2) // 忽略元素的顺序
	IgnoreExtraItems  = Strategy(1 << 3) // 忽略多余的元素
	TreatNullAsAbsent = Strategy(1 << 4) // 将 null 视为字段缺失
	UnquoteExpand     = Strategy(1 << 5) // 解析引号里面的内容
)
View Source
const (
	MatchNone   = MatchResult(0) // 匹配失败
	MatchPrefix = MatchResult(1) // 前缀匹配
	MatchFull   = MatchResult(2) // 全部匹配
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsentValue

type AbsentValue string

type Comparator

type Comparator func(a, b interface{}) bool

Comparator 值比较器。

type Config

type Config struct {
	// contains filtered or unexported fields
}

func Path

func Path(path string) *Config

func (*Config) IgnoreArrayOrder

func (c *Config) IgnoreArrayOrder() *Config

func (*Config) IgnoreExtraItems

func (c *Config) IgnoreExtraItems() *Config

func (*Config) IgnorePath

func (c *Config) IgnorePath() *Config

func (*Config) IgnoreValue

func (c *Config) IgnoreValue() *Config

func (*Config) Match

func (c *Config) Match(path string) MatchResult

func (*Config) SetComparator

func (c *Config) SetComparator(comparator Comparator) *Config

func (*Config) TreatNullAsAbsent

func (c *Config) TreatNullAsAbsent() *Config

func (*Config) UnquoteExpand

func (c *Config) UnquoteExpand() *Config

type DiffItem

type DiffItem struct {
	A string
	B string
}

type DiffResult

type DiffResult struct {
	Differs map[string]DiffItem
	Ignores map[string]DiffItem
	Equals  map[string]DiffItem
}

func Diff

func Diff(a, b string, configs ...*Config) *DiffResult

Diff 比较 a,b 两个 JSON 字符串,返回它们异同之处。

type MatchResult

type MatchResult int

MatchResult 路径匹配结果。

type Strategy

type Strategy int

Strategy 比较策略。

type UnquoteString

type UnquoteString string

Jump to

Keyboard shortcuts

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