Documentation
¶
Overview ¶
Package json implements JSON codec for JSON Patch operations. Provides encoding and decoding functionality for JSON Patch operations with full RFC 6902 support.
Package json implements JSON Patch decoder functionality.
Package json implements JSON codec for JSON Patch operations.
Package json implements JSON Patch encoder functionality.
Package json implements JSON codec for JSON Patch operations. Provides encoding and decoding functionality for JSON Patch operations with full RFC 6902 support.
Index ¶
- Variables
- func Decode(operations []map[string]interface{}, options internal.JsonPatchOptions) ([]internal.Op, error)
- func DecodeJSON(data []byte, options internal.JsonPatchOptions) ([]internal.Op, error)
- func Encode(ops []internal.Op) ([]map[string]interface{}, error)
- func EncodeJSON(ops []internal.Op) ([]byte, error)
- func OperationToOp(operation map[string]interface{}, options internal.JsonPatchOptions) (internal.Op, error)
- func OperationToPredicateOp(operation map[string]interface{}, options internal.JsonPatchOptions) (internal.Op, error)
- type CompactOperation
- type Decoder
- type Encoder
- type JsonPatchOptions
- type Operation
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidPointer = errors.New("invalid pointer") ErrAddOpMissingValue = errors.New("add operation missing 'value' field") ErrReplaceOpMissingValue = errors.New("replace operation missing 'value' field") ErrNotOpRequiresOperand = errors.New("not operation requires at least one operand") ErrMissingValueField = errors.New("missing value field") ErrEmptyTypeList = errors.New("empty type list") ErrInvalidType = errors.New("invalid type") ErrNotOpRequiresValidOperand = errors.New("not operation requires a valid predicate operand") )
Decode operation errors - define clearly and concisely
var ( // Core field validation errors ErrOpMissingOpField = errors.New("operation missing 'op' field") ErrOpMissingPathField = errors.New("operation missing 'path' field") // Move/Copy operation errors ErrMoveOpMissingFrom = errors.New("move operation missing 'from' field") ErrCopyOpMissingFrom = errors.New("copy operation missing 'from' field") // Extended operation errors ErrIncOpMissingInc = errors.New("inc operation missing 'inc' field") ErrStrInsOpMissingPos = errors.New("str_ins operation missing 'pos' field") ErrStrInsOpMissingStr = errors.New("str_ins operation missing 'str' field") ErrStrDelOpMissingPos = errors.New("str_del operation missing 'pos' field") ErrStrDelOpMissingFields = errors.New("str_del operation missing 'str' or 'len' field") ErrSplitOpMissingPos = errors.New("split operation missing 'pos' field") ErrMergeOpMissingPos = errors.New("merge operation missing 'pos' field") // Predicate operation errors ErrTypeOpMissingValue = errors.New("type operation missing string 'value' field") ErrTestTypeOpMissingType = errors.New("test_type operation missing 'type' field") ErrTestStringOpMissingStr = errors.New("test_string operation missing 'str' field") ErrTestStringLenOpMissingLen = errors.New("test_string_len operation missing 'len' field") ErrContainsOpMissingValue = errors.New("contains operation missing 'value' field") ErrEndsOpMissingValue = errors.New("ends operation missing 'value' field") ErrStartsOpMissingValue = errors.New("starts operation missing 'value' field") ErrMatchesOpMissingValue = errors.New("matches operation missing 'value' field") ErrLessOpMissingValue = errors.New("less operation missing 'value' field") ErrMoreOpMissingValue = errors.New("more operation missing 'value' field") // Composite operation errors ErrAndOpMissingApply = errors.New("and operation missing 'apply' field") ErrOrOpMissingApply = errors.New("or operation missing 'apply' field") ErrNotOpMissingApply = errors.New("not operation missing 'apply' field") // Type errors ErrValueNotObject = errors.New("value is not an object") // Unknown operation error ErrCodecOpUnknown = errors.New("unknown operation") )
Functions ¶
func Decode ¶
func Decode(operations []map[string]interface{}, options internal.JsonPatchOptions) ([]internal.Op, error)
Decode converts JSON operations to Op instances.
func DecodeJSON ¶
DecodeJSON converts JSON bytes to Op instances.
func EncodeJSON ¶
EncodeJSON converts operations to JSON bytes.
func OperationToOp ¶
func OperationToOp(operation map[string]interface{}, options internal.JsonPatchOptions) (internal.Op, error)
OperationToOp converts JSON operation to Op instance.
func OperationToPredicateOp ¶
func OperationToPredicateOp(operation map[string]interface{}, options internal.JsonPatchOptions) (internal.Op, error)
OperationToPredicateOp converts JSON operation to PredicateOp instance.
Types ¶
type CompactOperation ¶
type CompactOperation = internal.CompactOperation
CompactOperation represents a compact format operation.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder provides JSON patch decoding functionality with configurable options.
func NewDecoder ¶
func NewDecoder(options internal.JsonPatchOptions) *Decoder
NewDecoder creates a new Decoder with the given options.
type Encoder ¶
type Encoder struct{}
Encoder provides JSON patch encoding functionality.
type JsonPatchOptions ¶
type JsonPatchOptions = internal.JsonPatchOptions
JsonPatchOptions contains options for JSON Patch operations.
type Operation ¶
Operation represents a JSON Patch operation in JSON format. This unified structure supports all standard and extended operation internal.
type Options ¶
type Options struct {
// CreateMatcher creates a regex matcher function for pattern matching operations
CreateMatcher func(pattern string, ignoreCase bool) func(string) bool
}
Options represents configuration options for JSON codec operations. Provides configurable regex matcher creation for matches operations.