{"modulePath":"github.com/kaptinlin/jsonpatch","version":"v0.7.10","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package compact\n\nPackage compact implements an array-based codec for JSON Patch operations.\n\n## Variables\n\n```go\nvar (\n\tErrMinLength         = errors.New(\"compact operation must have at least opcode and path\")\n\tErrPathNotString     = errors.New(\"compact operation path must be a string array\")\n\tErrInvalidArity      = errors.New(\"compact operation has invalid arity\")\n\tErrInvalidTrueMarker = errors.New(\"compact optional true marker must be 1\")\n\tErrNumberNotFinite   = errors.New(\"compact numeric field must be finite\")\n\tErrNumberNotInteger  = errors.New(\"compact positional field must be an integer\")\n\tErrNumberOutOfRange  = errors.New(\"compact positional field is outside the int range\")\n\tErrInvalidVariant    = errors.New(\"compact operation variant is invalid\")\n)\n```\nBase errors for compact operation validation.\n\n```go\nvar (\n\tErrAddMissingValue     = errors.New(\"add operation requires value\")\n\tErrReplaceMissingValue = errors.New(\"replace operation requires value\")\n\tErrMoveMissingFrom     = errors.New(\"move operation requires from path\")\n\tErrMoveFromNotString   = errors.New(\"move operation from must be a string\")\n\tErrCopyMissingFrom     = errors.New(\"copy operation requires from path\")\n\tErrCopyFromNotString   = errors.New(\"copy operation from must be a string\")\n\tErrTestMissingValue    = errors.New(\"test operation requires value\")\n)\n```\nCore operation (RFC 6902) errors.\n\n```go\nvar (\n\tErrIncMissingDelta      = errors.New(\"inc operation requires delta\")\n\tErrIncDeltaNotNumber    = errors.New(\"inc operation delta must be a number\")\n\tErrStrInsMissingFields  = errors.New(\"str_ins operation requires pos and str\")\n\tErrStrInsPosNotNumber   = errors.New(\"str_ins operation pos must be a number\")\n\tErrStrInsStrNotString   = errors.New(\"str_ins operation str must be a string\")\n\tErrStrDelMissingFields  = errors.New(\"str_del operation requires pos and len\")\n\tErrStrDelPosNotNumber   = errors.New(\"str_del operation pos must be a number\")\n\tErrStrDelLenNotNumber   = errors.New(\"str_del operation len must be a number\")\n\tErrSplitMissingPos      = errors.New(\"split operation requires pos\")\n\tErrSplitPosNotNumber    = errors.New(\"split operation pos must be a number\")\n\tErrSplitPropsNotObject  = errors.New(\"split operation props must be an object\")\n\tErrMergeMissingPos      = errors.New(\"merge operation requires pos\")\n\tErrMergePosNotNumber    = errors.New(\"merge operation pos must be a number\")\n\tErrMergePropsNotObject  = errors.New(\"merge operation props must be an object\")\n\tErrExtendMissingProps   = errors.New(\"extend operation requires props\")\n\tErrExtendPropsNotObject = errors.New(\"extend operation props must be an object\")\n)\n```\nExtended operation errors.\n\n```go\nvar (\n\tErrContainsMissingValue    = errors.New(\"contains operation requires value\")\n\tErrContainsValueNotString  = errors.New(\"contains operation value must be a string\")\n\tErrStartsMissingValue      = errors.New(\"starts operation requires value\")\n\tErrStartsValueNotString    = errors.New(\"starts operation value must be a string\")\n\tErrEndsMissingValue        = errors.New(\"ends operation requires value\")\n\tErrEndsValueNotString      = errors.New(\"ends operation value must be a string\")\n\tErrTypeMissingType         = errors.New(\"type operation requires type\")\n\tErrTypeNotString           = errors.New(\"type operation type must be a string\")\n\tErrTestTypeMissingTypes    = errors.New(\"test_type operation requires types\")\n\tErrTestTypeTypesNotArray   = errors.New(\"test_type operation types must be an array\")\n\tErrTestStringMissingPos    = errors.New(\"test_string operation requires pos\")\n\tErrTestStringPosNotNumber  = errors.New(\"test_string operation pos must be a number\")\n\tErrTestStringMissingStr    = errors.New(\"test_string operation requires str\")\n\tErrTestStringNotString     = errors.New(\"test_string operation str must be a string\")\n\tErrTestStringLenMissingLen = errors.New(\"test_string_len operation requires len\")\n\tErrTestStringLenNotNumber  = errors.New(\"test_string_len operation len must be a number\")\n\tErrInMissingValues         = errors.New(\"in operation requires values\")\n\tErrInValuesNotArray        = errors.New(\"in operation values must be an array\")\n\tErrLessMissingValue        = errors.New(\"less operation requires value\")\n\tErrLessValueNotNumber      = errors.New(\"less operation value must be a number\")\n\tErrMoreMissingValue        = errors.New(\"more operation requires value\")\n\tErrMoreValueNotNumber      = errors.New(\"more operation value must be a number\")\n\tErrMatchesMissingPattern   = errors.New(\"matches operation requires pattern\")\n\tErrMatchesPatternNotString = errors.New(\"matches operation pattern must be a string\")\n)\n```\nPredicate operation errors.\n\n```go\nvar (\n\tErrAndMissingOps      = errors.New(\"and operation requires ops\")\n\tErrOrMissingOps       = errors.New(\"or operation requires ops\")\n\tErrNotMissingOps      = errors.New(\"not operation requires ops\")\n\tErrPredicateNotArray  = errors.New(\"predicate ops must be an array\")\n\tErrPredicateOpInvalid = errors.New(\"predicate op must be an array\")\n\tErrNotPredicate       = errors.New(\"decoded operation is not a predicate\")\n\tErrNotSinglePredicate = errors.New(\"not operation requires exactly one predicate\")\n)\n```\nComposite operation errors.\n\n```go\nvar (\n\tErrUnsupportedOp      = errors.New(\"unsupported operation type\")\n\tErrUnknownStringCode  = errors.New(\"unknown string opcode\")\n\tErrInvalidCodeType    = errors.New(\"invalid opcode type\")\n\tErrUnknownNumericCode = errors.New(\"unknown numeric opcode\")\n\tErrNotFloat64         = errors.New(\"cannot convert to float64\")\n\tErrExpectedArray      = errors.New(\"expected array\")\n\tErrExpectedString     = errors.New(\"expected string in array\")\n)\n```\nResolution and conversion errors.\n\n## Functions\n\n```go\nfunc Decode(ops []Op) ([]internal.Op, error)\n```\nDecode decodes compact format operations.\n\n```go\nfunc DecodeJSON(data []byte) ([]internal.Op, error)\n```\nDecodeJSON decodes compact format JSON bytes into operations.\n\n```go\nfunc EncodeJSON(ops []internal.Op, opts ...Option) ([]byte, error)\n```\nEncodeJSON encodes operations into compact JSON bytes.\n\n## Types\n\n```go\ntype Code int\n```\nCode represents a numeric operation code in compact format.\n\n```go\nconst (\n\t// JSON Patch (RFC 6902)\n\tCodeAdd     Code = Code(internal.OpAddCode)\n\tCodeRemove  Code = Code(internal.OpRemoveCode)\n\tCodeReplace Code = Code(internal.OpReplaceCode)\n\tCodeCopy    Code = Code(internal.OpCopyCode)\n\tCodeMove    Code = Code(internal.OpMoveCode)\n\tCodeTest    Code = Code(internal.OpTestCode)\n\n\t// String editing\n\tCodeStrIns Code = Code(internal.OpStrInsCode)\n\tCodeStrDel Code = Code(internal.OpStrDelCode)\n\n\t// Extra\n\tCodeFlip Code = Code(internal.OpFlipCode)\n\tCodeInc  Code = Code(internal.OpIncCode)\n\n\t// Slate.js\n\tCodeSplit  Code = Code(internal.OpSplitCode)\n\tCodeMerge  Code = Code(internal.OpMergeCode)\n\tCodeExtend Code = Code(internal.OpExtendCode)\n\n\t// JSON Predicate\n\tCodeContains      Code = Code(internal.OpContainsCode)\n\tCodeDefined       Code = Code(internal.OpDefinedCode)\n\tCodeEnds          Code = Code(internal.OpEndsCode)\n\tCodeIn            Code = Code(internal.OpInCode)\n\tCodeLess          Code = Code(internal.OpLessCode)\n\tCodeMatches       Code = Code(internal.OpMatchesCode)\n\tCodeMore          Code = Code(internal.OpMoreCode)\n\tCodeStarts        Code = Code(internal.OpStartsCode)\n\tCodeUndefined     Code = Code(internal.OpUndefinedCode)\n\tCodeTestType      Code = Code(internal.OpTestTypeCode)\n\tCodeTestString    Code = Code(internal.OpTestStringCode)\n\tCodeTestStringLen Code = Code(internal.OpTestStringLenCode)\n\tCodeType          Code = Code(internal.OpTypeCode)\n\tCodeAnd           Code = Code(internal.OpAndCode)\n\tCodeNot           Code = Code(internal.OpNotCode)\n\tCodeOr            Code = Code(internal.OpOrCode)\n)\n```\nNumeric operation codes derived from internal constants.\n\n```go\ntype Decoder struct{}\n```\nDecoder decodes compact format operations.\n\n```go\nfunc NewDecoder() *Decoder\n```\nNewDecoder creates a new compact decoder.\n\n```go\nfunc (d *Decoder) Decode(raw Op) (internal.Op, error)\n```\nDecode decodes a single compact operation.\n\n```go\nfunc (d *Decoder) DecodeSlice(ops []Op) ([]internal.Op, error)\n```\nDecodeSlice decodes multiple compact operations.\n\n```go\ntype Encoder struct {\n\t// contains filtered or unexported fields\n}\n```\nEncoder encodes operations into compact format.\n\n```go\nfunc NewEncoder(opts ...Option) *Encoder\n```\nNewEncoder creates a new compact encoder with the given options.\n\n```go\nfunc (e *Encoder) Encode(o internal.Op) (Op, error)\n```\nEncode encodes a single operation into compact format.\n\n```go\nfunc (e *Encoder) EncodeSlice(ops []internal.Op) ([]Op, error)\n```\nEncodeSlice encodes multiple operations into compact format.\n\n```go\ntype Op []any\n```\nOp represents a compact format operation as an array.\n\n```go\nfunc Encode(ops []internal.Op, opts ...Option) ([]Op, error)\n```\nEncode encodes operations into compact format.\n\n```go\ntype Operation = internal.CompactOperation\n```\nOperation represents a compact format operation.\n\n```go\ntype Option func(*Options)\n```\nOption is a functional option for configuring the encoder.\n\n```go\nfunc WithStringOpcode(useString bool) Option\n```\nWithStringOpcode configures the encoder to use string opcodes.\n\n```go\ntype Options struct {\n\t// StringOpcode uses string opcodes instead of numeric ones.\n\tStringOpcode bool\n}\n```\nOptions configures the compact encoder behavior.\n\n","path":"github.com/kaptinlin/jsonpatch/codec/compact","name":"compact","synopsis":"Package compact implements an array-based codec for JSON Patch operations.","isRedistributable":true}
