Documentation
¶
Index ¶
- type Compare
- type CompareResult
- type Merge
- func (m *Merge) DeepMerge(target, source map[string]interface{}) map[string]interface{}
- func (m *Merge) DeepMergeWithOptions(target, source map[string]interface{}, opts *MergeOptions) map[string]interface{}
- func (m *Merge) MergeMultiple(objects ...map[string]interface{}) map[string]interface{}
- func (m *Merge) MergeMultipleWithOptions(opts *MergeOptions, objects ...map[string]interface{}) map[string]interface{}
- func (m *Merge) MergePatch(target, patch map[string]interface{}) map[string]interface{}
- type MergeOptions
- type PathUtil
- func (p *PathUtil) BuildPath(parts ...string) string
- func (p *PathUtil) GetLastPart(path string) string
- func (p *PathUtil) GetParentPath(path string) string
- func (p *PathUtil) IsRoot(path string) bool
- func (p *PathUtil) ParseArrayIndex(part string) (int, bool)
- func (p *PathUtil) ParsePath(path string) []string
- func (p *PathUtil) ResolvePath(data interface{}, path string) (interface{}, error)
- func (p *PathUtil) SetValueAtPath(data map[string]interface{}, path string, value interface{}) error
- func (p *PathUtil) ValidatePath(path string) error
- type RespUtil
- type Schema
- type SchemaType
- type SearchOptions
- type SearchResult
- type SearchUtil
- type ValidationError
- type ValidationUtil
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compare ¶
type Compare struct{}
Compare provides comparison functionality for JSON values
func NewCompare ¶
func NewCompare() *Compare
func (*Compare) Compare ¶
func (c *Compare) Compare(a, b interface{}) (CompareResult, error)
Compare numerically compares two JSON values
type CompareResult ¶
type CompareResult int
CompareResult represents the result of a comparison operation
const ( Less CompareResult = -1 Equal CompareResult = 0 Greater CompareResult = 1 )
type Merge ¶
type Merge struct{}
Merge provides JSON merging functionality
func (*Merge) DeepMergeWithOptions ¶
func (m *Merge) DeepMergeWithOptions(target, source map[string]interface{}, opts *MergeOptions) map[string]interface{}
DeepMergeWithOptions performs a deep merge with custom options
func (*Merge) MergeMultiple ¶
MergeMultiple merges multiple JSON objects together
func (*Merge) MergeMultipleWithOptions ¶
func (m *Merge) MergeMultipleWithOptions(opts *MergeOptions, objects ...map[string]interface{}) map[string]interface{}
MergeMultipleWithOptions merges multiple JSON objects with custom options
type MergeOptions ¶
type MergeOptions struct { // OverwriteExisting determines if existing values should be overwritten OverwriteExisting bool // MaxDepth sets the maximum recursion depth for deep merge (-1 for unlimited) MaxDepth int // SkipNullValues determines if null values should be skipped during merge SkipNullValues bool }
MergeOptions holds configuration for merge operations
func DefaultMergeOptions ¶
func DefaultMergeOptions() *MergeOptions
DefaultMergeOptions returns default merge options
type PathUtil ¶
type PathUtil struct{}
PathUtil provides path parsing and manipulation utilities for JSON operations
func (*PathUtil) GetLastPart ¶
GetLastPart returns the last component of the path
func (*PathUtil) GetParentPath ¶
GetParentPath returns the parent path of the given path
func (*PathUtil) ParseArrayIndex ¶
ParseArrayIndex extracts the index from an array accessor Example: "[0]" -> 0, true Example: "name" -> 0, false
func (*PathUtil) ParsePath ¶
ParsePath splits a JSON path into its component parts Example: "users.0.name" -> ["users", "0", "name"] Example: "users[0].name" -> ["users", "[0]", "name"]
func (*PathUtil) ResolvePath ¶
ResolvePath resolves a path against a JSON value and returns the target
func (*PathUtil) SetValueAtPath ¶
func (p *PathUtil) SetValueAtPath(data map[string]interface{}, path string, value interface{}) error
SetValueAtPath sets a value at the specified path in a JSON object
func (*PathUtil) ValidatePath ¶
ValidatePath checks if a path is syntactically valid
type RespUtil ¶
type RespUtil struct{}
RespUtil provides utilities for converting between JSON and RESP format
func (*RespUtil) JSONToRESP ¶
JSONToRESP converts a JSON value to RESP format
func (*RespUtil) RESPToJSON ¶
RESPToJSON converts a RESP value to JSON format
type Schema ¶
type Schema struct { Type SchemaType `json:"type"` Properties map[string]*Schema `json:"properties,omitempty"` Required []string `json:"required,omitempty"` Items *Schema `json:"items,omitempty"` MinLength *int `json:"minLength,omitempty"` MaxLength *int `json:"maxLength,omitempty"` Minimum *float64 `json:"minimum,omitempty"` Maximum *float64 `json:"maximum,omitempty"` Pattern *string `json:"pattern,omitempty"` Enum []interface{} `json:"enum,omitempty"` }
Schema represents a JSON schema structure
type SchemaType ¶
type SchemaType string
SchemaType represents the type of a JSON value
const ( TypeString SchemaType = "string" TypeNumber SchemaType = "number" TypeBoolean SchemaType = "boolean" TypeArray SchemaType = "array" TypeObject SchemaType = "object" TypeNull SchemaType = "null" )
type SearchOptions ¶
type SearchOptions struct { CaseSensitive bool // Case-sensitive search IncludeKeys bool // Search in keys IncludeValues bool // Search in values }
SearchOptions contains configuration for search operations
func DefaultSearchOptions ¶
func DefaultSearchOptions() *SearchOptions
DefaultSearchOptions returns default search options
type SearchResult ¶
type SearchResult struct { Path string // Path where the match was found Key string // Key that matched Value interface{} // Value that matched IsKey bool // Indicates if the match was in a key }
SearchResult represents a search match
type SearchUtil ¶
type SearchUtil struct{}
SearchUtil provides JSON search functionality
func NewSearchUtil ¶
func NewSearchUtil() *SearchUtil
NewSearchUtil creates a new instance of SearchUtil
func (*SearchUtil) Search ¶
func (s *SearchUtil) Search(jsonData, keyword string, opts *SearchOptions) []SearchResult
type ValidationError ¶
ValidationError represents a schema validation error
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationUtil ¶
type ValidationUtil struct{}
ValidationUtil provides JSON schema validation functionality
func NewValidationUtil ¶
func NewValidationUtil() *ValidationUtil
NewValidationUtil creates a new instance of ValidationUtil
func (*ValidationUtil) Validate ¶
func (v *ValidationUtil) Validate(value interface{}, schema *Schema) error
Validate validates a JSON value against a schema