jsondiff

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package jsondiff provides utilities for working with JSON types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONOpts

type JSONOpts struct {
	Primitive  TransformPrimitiveJSON
	Object     TransformObjectJSON
	Array      TransformArrayJSON
	Unknown    TransformUnknownJSON
	Sensitive  TransformSensitiveJSON
	TypeChange TransformTypeChangeJSON
}

JSONOpts defines the external callback functions that callers should implement to process the supplied diffs.

func (JSONOpts) Transform

func (opts JSONOpts) Transform(change structured.Change) (computed.Diff, error)

Transform accepts a generic before and after value that is assumed to be JSON formatted and transforms it into a computed.Diff, using the callbacks supplied in the JSONOpts class.

type TransformArrayJSON

type TransformArrayJSON func([]computed.Diff, action.Action) computed.Diff

TransformArrayJSON is a callback function that processes an array JSON

type TransformObjectJSON

type TransformObjectJSON func(map[string]computed.Diff, action.Action) computed.Diff

TransformObjectJSON is a callback function that processes an object JSON

type TransformPrimitiveJSON

type TransformPrimitiveJSON func(before, after interface{}, ctype cty.Type, action action.Action) computed.Diff

TransformPrimitiveJSON is a callback function that processes a primitive JSON

type TransformSensitiveJSON

type TransformSensitiveJSON func(computed.Diff, bool, bool, action.Action) computed.Diff

TransformSensitiveJSON is a callback function that processes a sensitive JSON

type TransformTypeChangeJSON

type TransformTypeChangeJSON func(before, after computed.Diff, action action.Action) computed.Diff

TransformTypeChangeJSON is a callback function that processes a type change JSON

type TransformUnknownJSON

type TransformUnknownJSON func(computed.Diff, action.Action) computed.Diff

TransformUnknownJSON is a callback function that processes an unknown JSON

type Type

type Type string

Type represents the type of a JSON value

const (
	Number Type = "number"
	Object Type = "object"
	Array  Type = "array"
	Bool   Type = "bool"
	String Type = "string"
	Null   Type = "null"
)

Type constants

func GetType

func GetType(json interface{}) (Type, error)

GetType returns the type of the given JSON value

Jump to

Keyboard shortcuts

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