Documentation
ΒΆ
Index ΒΆ
- Constants
- Variables
- func ClampIndex(index, length int) int
- func Compact(dst *bytes.Buffer, src []byte) error
- func CompareJson(json1, json2 string) (bool, error)
- func ConvertFromScientific(s string) (string, error)
- func ConvertToBool(value any) (bool, bool)
- func ConvertToFloat64(value any) (float64, bool)
- func ConvertToInt(value any) (int, bool)
- func ConvertToInt64(value any) (int64, bool)
- func ConvertToString(value any) string
- func ConvertToUint64(value any) (uint64, bool)
- func CreateEmptyContainer(containerType string) any
- func DeepCopy(data any) (any, error)
- func Delete(jsonStr, path string, opts ...*ProcessorOptions) (string, error)
- func DeleteWithCleanNull(jsonStr, path string, opts ...*ProcessorOptions) (string, error)
- func Encode(value any, config ...*EncodeConfig) (string, error)
- func EncodeCompact(value any, config ...*EncodeConfig) (string, error)
- func EncodePretty(value any, config ...*EncodeConfig) (string, error)
- func EscapeJSONPointer(s string) string
- func Foreach(jsonStr string, fn func(key any, item *IterableValue))
- func ForeachNested(jsonStr string, fn func(key any, item *IterableValue))
- func ForeachReturn(jsonStr string, fn func(key any, item *IterableValue)) (string, error)
- func ForeachWithPath(jsonStr, path string, fn func(key any, item *IterableValue)) error
- func ForeachWithPathAndControl(jsonStr, path string, fn func(key any, value any) IteratorControl) error
- func FormatCompact(jsonStr string, opts ...*ProcessorOptions) (string, error)
- func FormatNumber(value any) string
- func FormatPretty(jsonStr string, opts ...*ProcessorOptions) (string, error)
- func Get(jsonStr, path string, opts ...*ProcessorOptions) (any, error)
- func GetArray(jsonStr, path string, opts ...*ProcessorOptions) ([]any, error)
- func GetArrayWithDefault(jsonStr, path string, defaultValue []any, opts ...*ProcessorOptions) []any
- func GetBool(jsonStr, path string, opts ...*ProcessorOptions) (bool, error)
- func GetBoolWithDefault(jsonStr, path string, defaultValue bool, opts ...*ProcessorOptions) bool
- func GetContainerSize(data any) int
- func GetFloat64(jsonStr, path string, opts ...*ProcessorOptions) (float64, error)
- func GetFloat64WithDefault(jsonStr, path string, defaultValue float64, opts ...*ProcessorOptions) float64
- func GetInt(jsonStr, path string, opts ...*ProcessorOptions) (int, error)
- func GetIntWithDefault(jsonStr, path string, defaultValue int, opts ...*ProcessorOptions) int
- func GetMultiple(jsonStr string, paths []string, opts ...*ProcessorOptions) (map[string]any, error)
- func GetObject(jsonStr, path string, opts ...*ProcessorOptions) (map[string]any, error)
- func GetObjectWithDefault(jsonStr, path string, defaultValue map[string]any, opts ...*ProcessorOptions) map[string]any
- func GetString(jsonStr, path string, opts ...*ProcessorOptions) (string, error)
- func GetStringWithDefault(jsonStr, path, defaultValue string, opts ...*ProcessorOptions) string
- func GetTyped[T any](jsonStr, path string, opts ...*ProcessorOptions) (T, error)
- func GetTypedWithDefault[T any](jsonStr, path string, defaultValue T, opts ...*ProcessorOptions) T
- func GetTypedWithProcessor[T any](processor *Processor, jsonStr, path string, opts ...*ProcessorOptions) (T, error)
- func GetWithDefault(jsonStr, path string, defaultValue any, opts ...*ProcessorOptions) any
- func HTMLEscape(dst *bytes.Buffer, src []byte)
- func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
- func IsContainer(data any) bool
- func IsInteger(s string) bool
- func IsLargeNumber(numStr string) bool
- func IsNumeric(s string) bool
- func IsScientificNotation(s string) bool
- func IsValidIndex(index, length int) bool
- func IsValidJson(jsonStr string) bool
- func IsValidPath(path string) bool
- func LoadFromFile(filename string) (string, error)
- func Marshal(v any) ([]byte, error)
- func MarshalIndent(v any, prefix, indent string) ([]byte, error)
- func MarshalToFile(path string, data any, pretty ...bool) error
- func MergeJson(json1, json2 string) (string, error)
- func NewArrayOperations(utils *processorUtils) *arrayOperations
- func NewDeleteOperations(utils *processorUtils, pathParser *pathParser, navigator *navigator, ...) *deleteOperations
- func NewExtractionOperations(utils *processorUtils) *extractionOperations
- func NewNavigator(pathParser *pathParser, utils *processorUtils) *navigator
- func NewPathParser() *pathParser
- func NewProcessorUtils() *processorUtils
- func NewSetOperations(utils *processorUtils, pathParser *pathParser, navigator *navigator, ...) *setOperations
- func NormalizeIndex(index, length int) int
- func ParseArrayIndexGlobal(indexStr string) int
- func ParseBool(s string) (bool, error)
- func ParseFloat(s string) (float64, error)
- func ParseInt(s string) (int, error)
- func PreservingUnmarshal(data []byte, v any, preserveNumbers bool) error
- func SafeConvertToInt64(value any) (int64, error)
- func SafeConvertToUint64(value any) (uint64, error)
- func SafeTypeAssert[T any](value any) (T, bool)
- func SanitizeKey(key string) string
- func SaveToFile(filePath string, data any, pretty ...bool) error
- func Set(jsonStr, path string, value any, opts ...*ProcessorOptions) (string, error)
- func SetGlobalProcessor(processor *Processor)
- func SetMultiple(jsonStr string, updates map[string]any, opts ...*ProcessorOptions) (string, error)
- func SetMultipleWithAdd(jsonStr string, updates map[string]any, opts ...*ProcessorOptions) (string, error)
- func SetWithAdd(jsonStr, path string, value any) (string, error)
- func ShutdownGlobalProcessor()
- func SmartNumberConversion(value any) any
- func TestProcessorResourcePools(processor *Processor) bool
- func TypeSafeConvert[T any](value any) (T, error)
- func UnescapeJSONPointer(s string) string
- func UnifiedTypeConversion[T any](value any) (T, bool)
- func Unmarshal(data []byte, v any) error
- func UnmarshalFromFile(path string, v any) error
- func Valid(data []byte) bool
- func ValidateConfig(config *Config) error
- func ValidateOptions(options *ProcessorOptions) error
- func ValidatePath(path string) error
- func WrapError(err error, op, message string) error
- func WrapPathError(err error, op, path, message string) error
- type ArrayExtensionError
- type ArrayExtensionNeededError
- type ArrayHelper
- func (ah *ArrayHelper) ClampIndex(index, length int) int
- func (ah *ArrayHelper) CompactArray(arr []any) []any
- func (ah *ArrayHelper) ExtendArray(arr []any, targetLength int) []any
- func (ah *ArrayHelper) GetElement(arr []any, index int) (any, bool)
- func (ah *ArrayHelper) NormalizeIndex(index, length int) int
- func (ah *ArrayHelper) ParseArrayIndex(indexStr string) int
- func (ah *ArrayHelper) PerformSlice(arr []any, start, end, step int) []any
- func (ah *ArrayHelper) SetElement(arr []any, index int, value any) bool
- func (ah *ArrayHelper) ValidateBounds(index, length int) bool
- type BatchOperation
- type BatchResult
- type BenchmarkHelper
- type CacheKey
- type CacheStats
- type CheckResult
- type ComplexDeleteProcessor
- type ConcurrencyTester
- type Config
- func (c *Config) AllowComments() bool
- func (c *Config) Clone() *Config
- func (c *Config) GetCacheTTL() time.Duration
- func (c *Config) GetMaxCacheSize() int
- func (c *Config) GetMaxConcurrency() int
- func (c *Config) GetMaxJSONSize() int64
- func (c *Config) GetMaxNestingDepth() int
- func (c *Config) GetMaxPathDepth() int
- func (c *Config) GetSecurityLimits() map[string]any
- func (c *Config) IsCacheEnabled() bool
- func (c *Config) IsHealthCheckEnabled() bool
- func (c *Config) IsMetricsEnabled() bool
- func (c *Config) IsStrictMode() bool
- func (c *Config) PreserveNumbers() bool
- func (c *Config) ShouldCleanupNulls() bool
- func (c *Config) ShouldCompactArrays() bool
- func (c *Config) ShouldCreatePaths() bool
- func (c *Config) ShouldValidateFilePath() bool
- func (c *Config) ShouldValidateInput() bool
- func (c *Config) Validate() error
- type ConfigInterface
- type CustomEncoder
- type Decoder
- type DeletionTarget
- type Delim
- type DetailedStats
- type EncodeConfig
- type Encoder
- type ErrorClassifier
- type ExtractionContext
- type ExtractionGroup
- type HealthStatus
- type InvalidUnmarshalError
- type IterableValue
- func (iv *IterableValue) Exists(key string) bool
- func (iv *IterableValue) ForeachNested(path string, fn func(key any, item *IterableValue))
- func (iv *IterableValue) Get(path string) any
- func (iv *IterableValue) GetArray(key string) []any
- func (iv *IterableValue) GetBool(key string) bool
- func (iv *IterableValue) GetBoolWithDefault(key string, defaultValue bool) bool
- func (iv *IterableValue) GetFloat64(key string) float64
- func (iv *IterableValue) GetFloat64WithDefault(key string, defaultValue float64) float64
- func (iv *IterableValue) GetInt(key string) int
- func (iv *IterableValue) GetIntWithDefault(key string, defaultValue int) int
- func (iv *IterableValue) GetObject(key string) map[string]any
- func (iv *IterableValue) GetString(key string) string
- func (iv *IterableValue) GetStringWithDefault(key string, defaultValue string) string
- func (iv *IterableValue) GetWithDefault(key string, defaultValue any) any
- func (iv *IterableValue) IsEmpty(key string) bool
- func (iv *IterableValue) IsEmptyData() bool
- func (iv *IterableValue) IsNull(key string) bool
- func (iv *IterableValue) IsNullData() bool
- type Iterator
- type IteratorControl
- type JsonsError
- type Marshaler
- type MarshalerError
- type MemoryTracker
- type MetricsCollector
- type NavigationResult
- type Number
- type NumberPreservingDecoder
- type NumberPreservingValue
- type Operation
- type OperationContext
- type PathInfo
- type PathSegment
- type PathSegmentInfo
- type Processor
- func (p *Processor) ClearCache()
- func (p *Processor) Close() error
- func (p *Processor) Compact(jsonStr string, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) Delete(jsonStr, path string, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) EncodeBatch(pairs map[string]any, pretty bool, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) EncodeFields(value any, fields []string, pretty bool, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) EncodeStream(values any, pretty bool, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) EncodeStreamWithOptions(values any, encOpts *EncodeConfig, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) EncodeWithConfig(value any, config *EncodeConfig, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) EncodeWithOptions(value any, encOpts *EncodeConfig, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) EncodeWithTags(value any, pretty bool, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) Foreach(jsonStr string, fn func(key any, item *IterableValue))
- func (p *Processor) ForeachNested(jsonStr string, fn func(key any, item *IterableValue))
- func (p *Processor) ForeachReturn(jsonStr string, fn func(key any, item *IterableValue)) (string, error)
- func (p *Processor) ForeachWithPath(jsonStr, path string, fn func(key any, item *IterableValue)) error
- func (p *Processor) ForeachWithPathAndControl(jsonStr, path string, fn func(key any, value any) IteratorControl) error
- func (p *Processor) ForeachWithPathAndIterator(jsonStr, path string, ...) error
- func (p *Processor) FormatPretty(jsonStr string, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) Get(jsonStr, path string, opts ...*ProcessorOptions) (any, error)
- func (p *Processor) GetConfig() *Config
- func (p *Processor) GetHealthStatus() HealthStatus
- func (p *Processor) GetMultiple(jsonStr string, paths []string, opts ...*ProcessorOptions) (map[string]any, error)
- func (p *Processor) GetStats() Stats
- func (p *Processor) IsClosed() bool
- func (p *Processor) LoadFromFile(filePath string, opts ...*ProcessorOptions) (any, error)
- func (p *Processor) LoadFromReader(reader io.Reader, opts ...*ProcessorOptions) (any, error)
- func (p *Processor) Marshal(value any, opts ...*ProcessorOptions) ([]byte, error)
- func (p *Processor) MarshalIndent(value any, prefix, indent string, opts ...*ProcessorOptions) ([]byte, error)
- func (p *Processor) MarshalToFile(path string, data any, pretty ...bool) error
- func (p *Processor) Parse(jsonStr string, target any, opts ...*ProcessorOptions) error
- func (p *Processor) ProcessBatch(operations []BatchOperation, opts ...*ProcessorOptions) ([]BatchResult, error)
- func (p *Processor) SafeGet(jsonStr, path string) TypeSafeAccessResult
- func (p *Processor) SaveToFile(filePath string, data any, pretty ...bool) error
- func (p *Processor) SaveToWriter(writer io.Writer, data any, pretty bool, opts ...*ProcessorOptions) error
- func (p *Processor) Set(jsonStr, path string, value any, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) SetLogger(logger *slog.Logger)
- func (p *Processor) SetMultiple(jsonStr string, updates map[string]any, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) ToJsonString(value any, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) ToJsonStringPretty(value any, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) ToJsonStringStandard(value any, opts ...*ProcessorOptions) (string, error)
- func (p *Processor) Unmarshal(data []byte, v any, opts ...*ProcessorOptions) error
- func (p *Processor) UnmarshalFromFile(path string, v any, opts ...*ProcessorOptions) error
- func (p *Processor) Valid(jsonStr string, opts ...*ProcessorOptions) (bool, error)
- func (p *Processor) ValidateSchema(jsonStr string, schema *Schema, opts ...*ProcessorOptions) ([]ValidationError, error)
- func (p *Processor) WarmupCache(jsonStr string, paths []string, opts ...*ProcessorOptions) (*WarmupResult, error)
- type ProcessorCache
- type ProcessorConfig
- type ProcessorConfigAdapter
- func (pca *ProcessorConfigAdapter) AllowComments() bool
- func (pca *ProcessorConfigAdapter) GetCacheTTL() time.Duration
- func (pca *ProcessorConfigAdapter) GetMaxCacheSize() int
- func (pca *ProcessorConfigAdapter) GetMaxConcurrency() int
- func (pca *ProcessorConfigAdapter) GetMaxJSONSize() int64
- func (pca *ProcessorConfigAdapter) GetMaxNestingDepth() int
- func (pca *ProcessorConfigAdapter) GetMaxPathDepth() int
- func (pca *ProcessorConfigAdapter) IsCacheEnabled() bool
- func (pca *ProcessorConfigAdapter) IsHealthCheckEnabled() bool
- func (pca *ProcessorConfigAdapter) IsMetricsEnabled() bool
- func (pca *ProcessorConfigAdapter) IsStrictMode() bool
- func (pca *ProcessorConfigAdapter) PreserveNumbers() bool
- func (pca *ProcessorConfigAdapter) ShouldCleanupNulls() bool
- func (pca *ProcessorConfigAdapter) ShouldCompactArrays() bool
- func (pca *ProcessorConfigAdapter) ShouldCreatePaths() bool
- func (pca *ProcessorConfigAdapter) ShouldValidateFilePath() bool
- func (pca *ProcessorConfigAdapter) ShouldValidateInput() bool
- type ProcessorMetrics
- type ProcessorOptions
- type PropertyAccessResult
- type RateLimiter
- type RecursiveProcessor
- type ResourceManagerStats
- type ResourceMonitor
- func (rm *ResourceMonitor) CheckForLeaks() []string
- func (rm *ResourceMonitor) GetMemoryEfficiency() float64
- func (rm *ResourceMonitor) GetPoolEfficiency() float64
- func (rm *ResourceMonitor) GetStats() ResourceStats
- func (rm *ResourceMonitor) RecordAllocation(bytes int64)
- func (rm *ResourceMonitor) RecordDeallocation(bytes int64)
- func (rm *ResourceMonitor) RecordOperation(duration time.Duration)
- func (rm *ResourceMonitor) RecordPoolEviction()
- func (rm *ResourceMonitor) RecordPoolHit()
- func (rm *ResourceMonitor) RecordPoolMiss()
- func (rm *ResourceMonitor) Reset()
- type ResourcePoolStats
- type ResourceStats
- type RootDataTypeConversionError
- type Schema
- func (s *Schema) HasMaxItems() bool
- func (s *Schema) HasMaxLength() bool
- func (s *Schema) HasMaximum() bool
- func (s *Schema) HasMinItems() bool
- func (s *Schema) HasMinLength() bool
- func (s *Schema) HasMinimum() bool
- func (s *Schema) SetExclusiveMaximum(exclusive bool) *Schema
- func (s *Schema) SetExclusiveMinimum(exclusive bool) *Schema
- func (s *Schema) SetMaxItems(maxItems int) *Schema
- func (s *Schema) SetMaxLength(maxLength int) *Schema
- func (s *Schema) SetMaximum(maximum float64) *Schema
- func (s *Schema) SetMinItems(minItems int) *Schema
- func (s *Schema) SetMinLength(minLength int) *Schema
- func (s *Schema) SetMinimum(minimum float64) *Schema
- type SecurityValidator
- type ShardStats
- type SimpleCacheImpl
- type Stats
- type SyntaxError
- type TestDataGenerator
- type TestHelper
- func (h *TestHelper) AssertEqual(expected, actual any, msgAndArgs ...any)
- func (h *TestHelper) AssertError(err error, msgAndArgs ...any)
- func (h *TestHelper) AssertErrorContains(err error, contains string, msgAndArgs ...any)
- func (h *TestHelper) AssertFalse(condition bool, msgAndArgs ...any)
- func (h *TestHelper) AssertNil(value any, msgAndArgs ...any)
- func (h *TestHelper) AssertNoError(err error, msgAndArgs ...any)
- func (h *TestHelper) AssertNoPanic(fn func(), msgAndArgs ...any)
- func (h *TestHelper) AssertNotEqual(expected, actual any, msgAndArgs ...any)
- func (h *TestHelper) AssertNotNil(value any, msgAndArgs ...any)
- func (h *TestHelper) AssertPanic(fn func(), msgAndArgs ...any)
- func (h *TestHelper) AssertTrue(condition bool, msgAndArgs ...any)
- type TextMarshaler
- type TextUnmarshaler
- type Token
- type TypeSafeAccessResult
- type TypeSafeResult
- type UnifiedResourceManager
- func (urm *UnifiedResourceManager) GetBuffer() []byte
- func (urm *UnifiedResourceManager) GetPathSegments() []PathSegment
- func (urm *UnifiedResourceManager) GetStats() ResourceManagerStats
- func (urm *UnifiedResourceManager) GetStringBuilder() *strings.Builder
- func (urm *UnifiedResourceManager) PerformMaintenance()
- func (urm *UnifiedResourceManager) PutBuffer(buf []byte)
- func (urm *UnifiedResourceManager) PutPathSegments(segments []PathSegment)
- func (urm *UnifiedResourceManager) PutStringBuilder(sb *strings.Builder)
- type UnmarshalTypeError
- type Unmarshaler
- type UnsupportedTypeError
- type UnsupportedValueError
- type ValidationError
- type Validator
- type WarmupResult
Constants ΒΆ
const ( // Buffer and Pool Sizes - Optimized for production workloads DefaultBufferSize = 1024 MaxPoolBufferSize = 16384 MinPoolBufferSize = 512 DefaultPathSegmentCap = 8 MaxPathSegmentCap = 128 DefaultStringBuilderSize = 256 // Cache Sizes - Balanced for performance and memory DefaultCacheSize = 128 MaxCacheEntries = 512 CacheCleanupKeepSize = 256 // Operation Limits - Secure defaults with reasonable headroom InvalidArrayIndex = -999999 DefaultMaxJSONSize = 100 * 1024 * 1024 // 100MB - reasonable for most use cases DefaultMaxSecuritySize = 10 * 1024 * 1024 DefaultMaxNestingDepth = 200 DefaultMaxObjectKeys = 100000 DefaultMaxArrayElements = 100000 DefaultMaxPathDepth = 50 DefaultMaxBatchSize = 2000 DefaultMaxConcurrency = 50 DefaultParallelThreshold = 10 // Timing and Intervals - Optimized for responsiveness MemoryPressureCheckInterval = 30 * time.Second PoolResetInterval = 60 * time.Second PoolResetIntervalPressure = 30 * time.Second CacheCleanupInterval = 30 * time.Second DeadlockCheckInterval = 30 * time.Second DeadlockThreshold = 30 * time.Second SlowOperationThreshold = 100 * time.Millisecond // Retry and Timeout - Production-ready settings MaxRetries = 3 BaseRetryDelay = 10 * time.Millisecond DefaultOperationTimeout = 30 * time.Second AcquireSlotRetryDelay = 1 * time.Millisecond // Path Validation - Secure but flexible MaxPathLength = 5000 MaxSegmentLength = 1024 MaxExtractionDepth = 10 MaxConsecutiveColons = 3 MaxConsecutiveBrackets = 3 // Cache TTL DefaultCacheTTL = 5 * time.Minute // JSON processing thresholds SmallJSONThreshold = 256 // Threshold for lightweight JSON normalization MediumJSONThreshold = 1024 // Threshold for full JSON normalization // Cache key constants CacheKeyHashLength = 32 // Length for cache key hash SmallJSONCacheLimit = 2048 // Limit for caching small JSON strings EstimatedKeyOverhead = 32 // Estimated overhead for cache key generation LargeJSONKeyOverhead = 64 // Overhead for large JSON cache keys MaxCacheKeyLength = 500 // Maximum allowed cache key length // Validation constants ValidationBOMPrefix = "\uFEFF" // UTF-8 BOM prefix to detect and remove )
const ( ErrCodeInvalidJSON = "ERR_INVALID_JSON" ErrCodePathNotFound = "ERR_PATH_NOT_FOUND" ErrCodeTypeMismatch = "ERR_TYPE_MISMATCH" ErrCodeSizeLimit = "ERR_SIZE_LIMIT" ErrCodeDepthLimit = "ERR_DEPTH_LIMIT" ErrCodeSecurityViolation = "ERR_SECURITY_VIOLATION" ErrCodeOperationFailed = "ERR_OPERATION_FAILED" ErrCodeTimeout = "ERR_TIMEOUT" ErrCodeConcurrencyLimit = "ERR_CONCURRENCY_LIMIT" ErrCodeProcessorClosed = "ERR_PROCESSOR_CLOSED" ErrCodeRateLimit = "ERR_RATE_LIMIT" )
Error codes for machine-readable error identification
Variables ΒΆ
var ( // Primary errors for common cases ErrInvalidJSON = errors.New("invalid JSON format") ErrPathNotFound = errors.New("path not found") ErrTypeMismatch = errors.New("type mismatch") ErrOperationFailed = errors.New("operation failed") ErrInvalidPath = errors.New("invalid path format") ErrProcessorClosed = errors.New("processor is closed") // Limit-related errors ErrSizeLimit = errors.New("size limit exceeded") ErrDepthLimit = errors.New("depth limit exceeded") ErrConcurrencyLimit = errors.New("concurrency limit exceeded") // Security and validation errors ErrSecurityViolation = errors.New("security violation detected") ErrUnsupportedPath = errors.New("unsupported path operation") // Resource and performance errors ErrCacheFull = errors.New("cache is full") ErrCacheDisabled = errors.New("cache is disabled") ErrOperationTimeout = errors.New("operation timeout") ErrResourceExhausted = errors.New("system resources exhausted") // Control flow errors (internal use) ErrIteratorControl = errors.New("iterator control signal") )
Core error definitions - simplified and optimized for performance
var DeletedMarker = &struct{ deleted bool }{deleted: true}
Special marker for deleted values
Functions ΒΆ
func ClampIndex ΒΆ
ClampIndex clamps an index to valid bounds for an array
func Compact ΒΆ
Compact appends to dst the JSON-encoded src with insignificant space characters elided.
func CompareJson ΒΆ
CompareJson compares two JSON strings for equality
func ConvertFromScientific ΒΆ
ConvertFromScientific converts a scientific notation string to regular number format
func ConvertToBool ΒΆ added in v1.0.4
ConvertToBool converts any value to bool
func ConvertToFloat64 ΒΆ added in v1.0.4
ConvertToFloat64 converts any value to float64
func ConvertToInt ΒΆ added in v1.0.4
ConvertToInt converts any value to int with comprehensive type support
func ConvertToInt64 ΒΆ added in v1.0.4
ConvertToInt64 converts any value to int64
func ConvertToString ΒΆ added in v1.0.4
ConvertToString converts any value to string (for backward compatibility)
func ConvertToUint64 ΒΆ added in v1.0.4
ConvertToUint64 converts any value to uint64
func CreateEmptyContainer ΒΆ
CreateEmptyContainer creates an empty container of the specified type
func Delete ΒΆ
func Delete(jsonStr, path string, opts ...*ProcessorOptions) (string, error)
Delete deletes a value from JSON at the specified path
func DeleteWithCleanNull ΒΆ
func DeleteWithCleanNull(jsonStr, path string, opts ...*ProcessorOptions) (string, error)
DeleteWithCleanNull removes a value from JSON and cleans up null values
func Encode ΒΆ
func Encode(value any, config ...*EncodeConfig) (string, error)
Encode converts any Go value to JSON string
func EncodeCompact ΒΆ
func EncodeCompact(value any, config ...*EncodeConfig) (string, error)
EncodeCompact converts any Go value to compact JSON string
func EncodePretty ΒΆ
func EncodePretty(value any, config ...*EncodeConfig) (string, error)
EncodePretty converts any Go value to pretty-formatted JSON string
func EscapeJSONPointer ΒΆ
EscapeJSONPointer escapes special characters for JSON Pointer
func Foreach ΒΆ
func Foreach(jsonStr string, fn func(key any, item *IterableValue))
Foreach iterates over JSON arrays or objects with simplified signature (for test compatibility)
func ForeachNested ΒΆ
func ForeachNested(jsonStr string, fn func(key any, item *IterableValue))
ForeachNested iterates over nested JSON structures
func ForeachReturn ΒΆ
func ForeachReturn(jsonStr string, fn func(key any, item *IterableValue)) (string, error)
ForeachReturn is a variant that returns error (for compatibility with test expectations)
func ForeachWithPath ΒΆ
func ForeachWithPath(jsonStr, path string, fn func(key any, item *IterableValue)) error
ForechWithPath iterates over JSON arrays or objects with simplified signature (for test compatibility)
func ForeachWithPathAndControl ΒΆ added in v1.0.8
func ForeachWithPathAndControl(jsonStr, path string, fn func(key any, value any) IteratorControl) error
ForeachWithPathAndControl Foreach iterates over JSON arrays or objects and applies a function This is the 3-parameter version used by most code
func FormatCompact ΒΆ
func FormatCompact(jsonStr string, opts ...*ProcessorOptions) (string, error)
FormatCompact removes whitespace from JSON
func FormatNumber ΒΆ
FormatNumber formats a number value as a string
func FormatPretty ΒΆ
func FormatPretty(jsonStr string, opts ...*ProcessorOptions) (string, error)
FormatPretty formats JSON with indentation
func Get ΒΆ
func Get(jsonStr, path string, opts ...*ProcessorOptions) (any, error)
Get retrieves a value from JSON at the specified path
func GetArray ΒΆ
func GetArray(jsonStr, path string, opts ...*ProcessorOptions) ([]any, error)
GetArray retrieves an array from JSON
func GetArrayWithDefault ΒΆ
func GetArrayWithDefault(jsonStr, path string, defaultValue []any, opts ...*ProcessorOptions) []any
func GetBool ΒΆ
func GetBool(jsonStr, path string, opts ...*ProcessorOptions) (bool, error)
GetBool retrieves a bool value from JSON
func GetBoolWithDefault ΒΆ
func GetBoolWithDefault(jsonStr, path string, defaultValue bool, opts ...*ProcessorOptions) bool
func GetContainerSize ΒΆ
GetContainerSize returns the size of a container
func GetFloat64 ΒΆ
func GetFloat64(jsonStr, path string, opts ...*ProcessorOptions) (float64, error)
GetFloat64 retrieves a float64 value from JSON
func GetFloat64WithDefault ΒΆ
func GetFloat64WithDefault(jsonStr, path string, defaultValue float64, opts ...*ProcessorOptions) float64
func GetInt ΒΆ
func GetInt(jsonStr, path string, opts ...*ProcessorOptions) (int, error)
GetInt retrieves an int value from JSON
func GetIntWithDefault ΒΆ
func GetIntWithDefault(jsonStr, path string, defaultValue int, opts ...*ProcessorOptions) int
func GetMultiple ΒΆ
GetMultiple retrieves multiple values from JSON using multiple path expressions
func GetObject ΒΆ
func GetObject(jsonStr, path string, opts ...*ProcessorOptions) (map[string]any, error)
GetObject retrieves an object from JSON
func GetObjectWithDefault ΒΆ
func GetString ΒΆ
func GetString(jsonStr, path string, opts ...*ProcessorOptions) (string, error)
GetString retrieves a string value from JSON
func GetStringWithDefault ΒΆ
func GetStringWithDefault(jsonStr, path, defaultValue string, opts ...*ProcessorOptions) string
Type-specific convenience functions with defaults
func GetTyped ΒΆ
func GetTyped[T any](jsonStr, path string, opts ...*ProcessorOptions) (T, error)
GetTyped retrieves a typed value from JSON at the specified path
func GetTypedWithDefault ΒΆ
func GetTypedWithDefault[T any](jsonStr, path string, defaultValue T, opts ...*ProcessorOptions) T
GetTypedWithDefault retrieves a typed value with a default fallback
func GetTypedWithProcessor ΒΆ
func GetTypedWithProcessor[T any](processor *Processor, jsonStr, path string, opts ...*ProcessorOptions) (T, error)
GetTypedWithProcessor retrieves a typed value from JSON using a specific processor
func GetWithDefault ΒΆ
func GetWithDefault(jsonStr, path string, defaultValue any, opts ...*ProcessorOptions) any
GetWithDefault retrieves a value from JSON with a default fallback
func HTMLEscape ΒΆ
HTMLEscape appends to dst the JSON-encoded src with HTML-safe escaping.
func IsContainer ΒΆ
IsContainer checks if the data is a container type (map or slice)
func IsLargeNumber ΒΆ
IsLargeNumber checks if a string represents a number that's too large for standard numeric types
func IsScientificNotation ΒΆ
IsScientificNotation checks if a string represents a number in scientific notation
func IsValidIndex ΒΆ
IsValidIndex checks if an index is valid for an array of given length
func IsValidJson ΒΆ
IsValidJson quickly checks if a string is valid JSON
func IsValidPath ΒΆ
IsValidPath checks if a path expression is valid
func LoadFromFile ΒΆ
LoadFromFile loads JSON data from a file
func Marshal ΒΆ
Marshal returns the JSON encoding of v. This function is 100% compatible with encoding/json.Marshal.
func MarshalIndent ΒΆ
MarshalIndent is like Marshal but applies indentation to format the output. This function is 100% compatible with encoding/json.MarshalIndent.
func MarshalToFile ΒΆ added in v1.0.6
MarshalToFile converts data to JSON and saves it to the specified file. This is a convenience function that combines Marshal and file writing operations.
Parameters:
- path: file path where JSON will be saved (directories are created automatically)
- data: any Go value to be marshaled to JSON
- pretty: optional parameter - true for formatted JSON, false for compact (default: false)
Returns error if marshaling fails or file cannot be written.
Example:
user := map[string]any{"name": "John", "age": 30}
err := json.MarshalToFile("data/user.json", user, true)
func NewArrayOperations ΒΆ
func NewArrayOperations(utils *processorUtils) *arrayOperations
NewArrayOperations creates a new array operations instance
func NewDeleteOperations ΒΆ
func NewDeleteOperations(utils *processorUtils, pathParser *pathParser, navigator *navigator, arrayOps *arrayOperations) *deleteOperations
NewDeleteOperations creates a new delete operations instance
func NewExtractionOperations ΒΆ
func NewExtractionOperations(utils *processorUtils) *extractionOperations
NewExtractionOperations creates a new extraction operations instance
func NewNavigator ΒΆ
func NewNavigator(pathParser *pathParser, utils *processorUtils) *navigator
NewNavigator creates a new navigator instance
func NewPathParser ΒΆ
func NewPathParser() *pathParser
NewPathParser creates a new path parser instance
func NewProcessorUtils ΒΆ
func NewProcessorUtils() *processorUtils
NewProcessorUtils creates a new processor utils instance
func NewSetOperations ΒΆ
func NewSetOperations(utils *processorUtils, pathParser *pathParser, navigator *navigator, arrayOps *arrayOperations) *setOperations
NewSetOperations creates a new set operations instance
func NormalizeIndex ΒΆ
NormalizeIndex normalizes an array index (handles negative indices)
func ParseArrayIndexGlobal ΒΆ added in v1.0.7
ParseArrayIndexGlobal is a package-level function for backward compatibility
func ParseFloat ΒΆ
ParseFloat parses a string to float64 with error handling
func PreservingUnmarshal ΒΆ
PreservingUnmarshal unmarshals JSON with number preservation
func SafeConvertToInt64 ΒΆ
SafeConvertToInt64 safely converts any value to int64 with error handling
func SafeConvertToUint64 ΒΆ
SafeConvertToUint64 safely converts any value to uint64 with error handling
func SafeTypeAssert ΒΆ
SafeTypeAssert performs a safe type assertion with generics
func SanitizeKey ΒΆ
SanitizeKey sanitizes a key for safe use in maps
func SaveToFile ΒΆ
SaveToFile saves JSON data to a file with optional formatting
func Set ΒΆ
func Set(jsonStr, path string, value any, opts ...*ProcessorOptions) (string, error)
Set sets a value in JSON at the specified path Returns:
- On success: modified JSON string and nil error
- On failure: original unmodified JSON string and error information
func SetGlobalProcessor ΒΆ
func SetGlobalProcessor(processor *Processor)
SetGlobalProcessor sets a custom global processor (thread-safe)
func SetMultiple ΒΆ
SetMultiple sets multiple values using a map of path-value pairs
func SetMultipleWithAdd ΒΆ
func SetMultipleWithAdd(jsonStr string, updates map[string]any, opts ...*ProcessorOptions) (string, error)
SetMultipleWithAdd sets multiple values with automatic path creation
func SetWithAdd ΒΆ
SetWithAdd sets a value with automatic path creation Returns:
- On success: modified JSON string and nil error
- On failure: original unmodified JSON string and error information
func ShutdownGlobalProcessor ΒΆ
func ShutdownGlobalProcessor()
ShutdownGlobalProcessor shuts down the global processor
func SmartNumberConversion ΒΆ
SmartNumberConversion provides intelligent number type conversion
func TestProcessorResourcePools ΒΆ
TestProcessorResourcePools tests processor resource pool functionality
func TypeSafeConvert ΒΆ
TypeSafeConvert attempts to convert a value to the target type safely
func UnescapeJSONPointer ΒΆ
UnescapeJSONPointer unescapes JSON Pointer special characters
func UnifiedTypeConversion ΒΆ added in v1.0.4
UnifiedTypeConversion provides optimized type conversion with comprehensive support
func Unmarshal ΒΆ
Unmarshal parses the JSON-encoded data and stores the result in v. This function is 100% compatible with encoding/json.Unmarshal.
func UnmarshalFromFile ΒΆ added in v1.0.6
UnmarshalFromFile reads JSON data from the specified file and unmarshals it into the provided value. This is a convenience function that combines file reading and Unmarshal operations.
Parameters:
- path: file path to read JSON from
- v: pointer to the value where JSON will be unmarshaled
Returns error if file cannot be read or JSON unmarshaling fails.
Example:
var user map[string]any
err := json.UnmarshalFromFile("data/user.json", &user)
// Or with a struct
var person Person
err := json.UnmarshalFromFile("data/person.json", &person)
func ValidateConfig ΒΆ
ValidateConfig validates configuration values and applies corrections
func ValidateOptions ΒΆ
func ValidateOptions(options *ProcessorOptions) error
ValidateOptions validates processor options with enhanced checks
func ValidatePath ΒΆ
ValidatePath validates a path expression and returns detailed error information
func WrapPathError ΒΆ added in v1.0.6
WrapPathError wraps an error with path context
Types ΒΆ
type ArrayExtensionError ΒΆ
type ArrayExtensionError struct {
CurrentLength int
RequiredLength int
TargetIndex int
Value any
Message string
ExtendedArray []any // For storing pre-created extended arrays
}
ArrayExtensionError represents an error that signals array extension is needed
func (*ArrayExtensionError) Error ΒΆ
func (e *ArrayExtensionError) Error() string
type ArrayExtensionNeededError ΒΆ
type ArrayExtensionNeededError struct {
RequiredLength int
CurrentLength int
Start int
End int
Step int
Value any
}
ArrayExtensionNeededError indicates that an array needs to be extended
func (*ArrayExtensionNeededError) Error ΒΆ
func (e *ArrayExtensionNeededError) Error() string
type ArrayHelper ΒΆ added in v1.0.7
type ArrayHelper struct{}
ArrayHelper provides centralized array operation utilities
func (*ArrayHelper) ClampIndex ΒΆ added in v1.0.7
func (ah *ArrayHelper) ClampIndex(index, length int) int
ClampIndex clamps an index to valid bounds [0, length]
func (*ArrayHelper) CompactArray ΒΆ added in v1.0.7
func (ah *ArrayHelper) CompactArray(arr []any) []any
CompactArray removes nil values and deletion markers from an array
func (*ArrayHelper) ExtendArray ΒΆ added in v1.0.7
func (ah *ArrayHelper) ExtendArray(arr []any, targetLength int) []any
ExtendArray extends an array to the specified length, filling with nil values
func (*ArrayHelper) GetElement ΒΆ added in v1.0.7
func (ah *ArrayHelper) GetElement(arr []any, index int) (any, bool)
GetElement safely gets an element from an array with bounds checking
func (*ArrayHelper) NormalizeIndex ΒΆ added in v1.0.7
func (ah *ArrayHelper) NormalizeIndex(index, length int) int
NormalizeIndex converts negative indices to positive indices
func (*ArrayHelper) ParseArrayIndex ΒΆ added in v1.0.7
func (ah *ArrayHelper) ParseArrayIndex(indexStr string) int
ParseArrayIndex parses an array index from a string (consolidated implementation)
func (*ArrayHelper) PerformSlice ΒΆ added in v1.0.7
func (ah *ArrayHelper) PerformSlice(arr []any, start, end, step int) []any
PerformSlice performs array slicing with step support (optimized)
func (*ArrayHelper) SetElement ΒΆ added in v1.0.7
func (ah *ArrayHelper) SetElement(arr []any, index int, value any) bool
SetElement safely sets an element in an array with bounds checking
func (*ArrayHelper) ValidateBounds ΒΆ added in v1.0.7
func (ah *ArrayHelper) ValidateBounds(index, length int) bool
ValidateBounds checks if an index is within valid bounds
type BatchOperation ΒΆ
type BatchOperation struct {
Type string `json:"type"` // "get", "set", "delete", "validate"
JSONStr string `json:"json_str"` // JSON string to operate on
Path string `json:"path"` // Path for the operation
Value any `json:"value"` // Value for set operations
ID string `json:"id"` // Unique identifier for this operation
}
BatchOperation represents a single operation in a batch
type BatchResult ΒΆ
type BatchResult struct {
ID string `json:"id"` // Operation ID
Result any `json:"result"` // Operation result
Error error `json:"error"` // Operation error, if any
}
BatchResult represents the result of a batch operation
type BenchmarkHelper ΒΆ
type BenchmarkHelper struct {
// contains filtered or unexported fields
}
BenchmarkHelper provides utilities for benchmark tests
func NewBenchmarkHelper ΒΆ
func NewBenchmarkHelper(b *testing.B) *BenchmarkHelper
NewBenchmarkHelper creates a new benchmark helper
func (*BenchmarkHelper) MeasureMemory ΒΆ
func (bh *BenchmarkHelper) MeasureMemory(fn func())
MeasureMemory measures memory allocations during benchmark
type CacheStats ΒΆ
type CacheStats struct {
HitCount int64 `json:"hit_count"` // Total cache hits
MissCount int64 `json:"miss_count"` // Total cache misses
TotalMemory int64 `json:"total_memory"` // Total memory usage in bytes
HitRatio float64 `json:"hit_ratio"` // Cache hit ratio
MemoryEfficiency float64 `json:"memory_efficiency"` // Memory efficiency (hits per MB)
Evictions int64 `json:"evictions"` // Total evictions performed
ShardCount int `json:"shard_count"` // Number of cache shards
ShardStats []ShardStats `json:"shard_stats"` // Per-shard statistics
}
CacheStats provides comprehensive cache statistics
type CheckResult ΒΆ
CheckResult represents the result of a single health check
type ComplexDeleteProcessor ΒΆ
type ComplexDeleteProcessor struct {
// contains filtered or unexported fields
}
ComplexDeleteProcessor handles complex path deletions with reverse mapping
func NewComplexDeleteProcessor ΒΆ
func NewComplexDeleteProcessor(p *Processor) *ComplexDeleteProcessor
NewComplexDeleteProcessor creates a new complex delete processor
func (*ComplexDeleteProcessor) DeleteWithReverseMapping ΒΆ
func (cdp *ComplexDeleteProcessor) DeleteWithReverseMapping(data any, path string) error
DeleteWithReverseMapping performs deletion using reverse mapping for complex paths
type ConcurrencyTester ΒΆ
type ConcurrencyTester struct {
// contains filtered or unexported fields
}
ConcurrencyTester helps test concurrent operations
func NewConcurrencyTester ΒΆ
func NewConcurrencyTester(t *testing.T, concurrency, iterations int) *ConcurrencyTester
NewConcurrencyTester creates a new concurrency tester
func (*ConcurrencyTester) Run ΒΆ
func (ct *ConcurrencyTester) Run(operation func(workerID, iteration int) error)
Run runs concurrent test operations
type Config ΒΆ
type Config struct {
// Cache settings
MaxCacheSize int `json:"max_cache_size"` // Maximum number of cache entries
CacheTTL time.Duration `json:"cache_ttl"` // Time-to-live for cache entries
EnableCache bool `json:"enable_cache"` // Whether to enable caching
// Size limits
MaxJSONSize int64 `json:"max_json_size"` // Maximum JSON size in bytes
MaxPathDepth int `json:"max_path_depth"` // Maximum path depth
MaxBatchSize int `json:"max_batch_size"` // Maximum batch operation size
// Security limits (configurable)
MaxNestingDepthSecurity int `json:"max_nesting_depth_security"` // Maximum nesting depth for security validation (default: 50)
MaxSecurityValidationSize int64 `json:"max_security_validation_size"` // Maximum size for security validation in bytes (default: 100MB)
MaxObjectKeys int `json:"max_object_keys"` // Maximum number of keys in JSON objects (default: 10000)
MaxArrayElements int `json:"max_array_elements"` // Maximum number of elements in arrays (default: 10000)
// Concurrency settings
MaxConcurrency int `json:"max_concurrency"` // Maximum concurrent operations
ParallelThreshold int `json:"parallel_threshold"` // Threshold for parallel processing
// Processing options
EnableValidation bool `json:"enable_validation"` // Enable input validation
StrictMode bool `json:"strict_mode"` // Enable strict parsing mode
CreatePaths bool `json:"create_paths"` // Automatically create missing paths in Set operations
CleanupNulls bool `json:"cleanup_nulls"` // Remove null values after deletion operations
CompactArrays bool `json:"compact_arrays"` // Remove all null values from arrays (not just trailing)
// Additional options for interface compatibility
EnableMetrics bool `json:"enable_metrics"` // Enable metrics collection
EnableHealthCheck bool `json:"enable_health_check"` // Enable health checking
AllowCommentsFlag bool `json:"allow_comments"` // Allow JSON with comments
PreserveNumbersFlag bool `json:"preserve_numbers"` // Preserve number format
ValidateInput bool `json:"validate_input"` // Validate input
MaxNestingDepth int `json:"max_nesting_depth"` // Maximum nesting depth
ValidateFilePath bool `json:"validate_file_path"` // Validate file paths
}
Config holds configuration for the JSON processor
func DefaultConfig ΒΆ
func DefaultConfig() *Config
DefaultConfig returns the default configuration with optimized settings
func HighSecurityConfig ΒΆ
func HighSecurityConfig() *Config
HighSecurityConfig returns a configuration with enhanced security settings
func LargeDataConfig ΒΆ
func LargeDataConfig() *Config
LargeDataConfig returns a configuration optimized for processing large JSON datasets
func (*Config) AllowComments ΒΆ
func (*Config) GetCacheTTL ΒΆ
func (*Config) GetMaxCacheSize ΒΆ
func (*Config) GetMaxConcurrency ΒΆ
func (*Config) GetMaxJSONSize ΒΆ
func (*Config) GetMaxNestingDepth ΒΆ
func (*Config) GetMaxPathDepth ΒΆ
func (*Config) GetSecurityLimits ΒΆ
GetSecurityLimits returns a summary of current security limits
func (*Config) IsCacheEnabled ΒΆ
ConfigInterface implementation methods
func (*Config) IsHealthCheckEnabled ΒΆ
func (*Config) IsMetricsEnabled ΒΆ
func (*Config) IsStrictMode ΒΆ
func (*Config) PreserveNumbers ΒΆ
func (*Config) ShouldCleanupNulls ΒΆ
func (*Config) ShouldCompactArrays ΒΆ
func (*Config) ShouldCreatePaths ΒΆ
func (*Config) ShouldValidateFilePath ΒΆ
func (*Config) ShouldValidateInput ΒΆ
type ConfigInterface ΒΆ added in v1.0.7
type ConfigInterface interface {
IsCacheEnabled() bool
GetMaxCacheSize() int
GetCacheTTL() time.Duration
GetMaxJSONSize() int64
GetMaxPathDepth() int
GetMaxConcurrency() int
IsMetricsEnabled() bool
IsStrictMode() bool
AllowComments() bool
PreserveNumbers() bool
ShouldCreatePaths() bool
ShouldCleanupNulls() bool
ShouldCompactArrays() bool
ShouldValidateInput() bool
GetMaxNestingDepth() int
}
ConfigInterface defines the interface for configuration objects
type CustomEncoder ΒΆ
type CustomEncoder struct {
// contains filtered or unexported fields
}
CustomEncoder provides advanced JSON encoding with configurable options
func NewCustomEncoder ΒΆ
func NewCustomEncoder(config *EncodeConfig) *CustomEncoder
NewCustomEncoder creates a new custom encoder with the given configuration
func (*CustomEncoder) Close ΒΆ
func (e *CustomEncoder) Close()
Close releases the encoder's buffers back to the pool
type Decoder ΒΆ
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads and decodes JSON values from an input stream. This type is fully compatible with encoding/json.Decoder.
func NewDecoder ΒΆ
NewDecoder returns a new decoder that reads from r. This function is fully compatible with encoding/json.NewDecoder.
The decoder introduces its own buffering and may read data from r beyond the JSON values requested.
func (*Decoder) Buffered ΒΆ
Buffered returns a reader of the data remaining in the Decoder's buffer. The reader is valid until the next call to Decode.
func (*Decoder) Decode ΒΆ
Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by v.
See the documentation for Unmarshal for details about the conversion of JSON into a Go value.
func (*Decoder) DisallowUnknownFields ΒΆ
func (dec *Decoder) DisallowUnknownFields()
DisallowUnknownFields causes the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.
func (*Decoder) InputOffset ΒΆ
InputOffset returns the input stream byte offset of the current decoder position. The offset gives the location of the end of the most recently returned token and the beginning of the next token.
func (*Decoder) More ΒΆ
More reports whether there is another element in the current array or object being parsed.
func (*Decoder) Token ΒΆ
Token returns the next JSON token in the input stream. At the end of the input stream, Token returns nil, io.EOF.
Token guarantees that the delimiters [ ] { } it returns are properly nested and matched: if Token encounters an unexpected delimiter in the input, it will return an error.
The input stream consists of zero or more JSON values, each separated by optional whitespace.
A Token holds one of these types:
Delim, for the four JSON delimiters [ ] { }
bool, for JSON booleans
float64, for JSON numbers
Number, for JSON numbers
string, for JSON string literals
nil, for JSON null
type DeletionTarget ΒΆ
type DeletionTarget struct {
Container any // The container (array or object) that holds the value to delete
Key any // The key (string for objects, int for arrays) to delete
Path string // The path to this target for debugging
}
DeletionTarget represents a specific location in the original data structure that needs to be deleted
type DetailedStats ΒΆ
type DetailedStats struct {
Stats Stats `json:"stats"`
// contains filtered or unexported fields
}
DetailedStats provides comprehensive processor statistics (internal debugging)
type EncodeConfig ΒΆ
type EncodeConfig struct {
Pretty bool `json:"pretty"`
Indent string `json:"indent"`
Prefix string `json:"prefix"`
EscapeHTML bool `json:"escape_html"`
SortKeys bool `json:"sort_keys"`
OmitEmpty bool `json:"omit_empty"`
ValidateUTF8 bool `json:"validate_utf8"`
MaxDepth int `json:"max_depth"`
DisallowUnknown bool `json:"disallow_unknown"`
// Number formatting options
PreserveNumbers bool `json:"preserve_numbers"` // Preserve original number format and avoid type conversion
FloatPrecision int `json:"float_precision"` // Precision for float formatting (-1 for automatic)
// Enhanced character escaping options
DisableEscaping bool `json:"disable_escaping"` // Disable all character escaping (except quotes and backslashes)
EscapeUnicode bool `json:"escape_unicode"` // Escape Unicode characters to \uXXXX format
EscapeSlash bool `json:"escape_slash"` // Escape forward slashes to \/
EscapeNewlines bool `json:"escape_newlines"` // Escape newlines to \n instead of literal newlines
EscapeTabs bool `json:"escape_tabs"` // Escape tabs to \t instead of literal tabs
// Null value handling
IncludeNulls bool `json:"include_nulls"` // Include null values in output (default: true)
// Custom escape characters
CustomEscapes map[rune]string `json:"custom_escapes,omitempty"` // Custom character escape mappings
}
EncodeConfig provides advanced encoding configuration (for complex use cases)
func DefaultEncodeConfig ΒΆ
func DefaultEncodeConfig() *EncodeConfig
DefaultEncodeConfig returns default encoding configuration
func NewCleanConfig ΒΆ
func NewCleanConfig() *EncodeConfig
NewCleanConfig creates a configuration that omits null and empty values
func NewCompactConfig ΒΆ
func NewCompactConfig() *EncodeConfig
NewCompactConfig returns configuration for compact JSON
func NewPrettyConfig ΒΆ
func NewPrettyConfig() *EncodeConfig
NewPrettyConfig returns configuration for pretty-printed JSON
func NewReadableConfig ΒΆ
func NewReadableConfig() *EncodeConfig
NewReadableConfig creates a configuration for human-readable JSON with minimal escaping
func NewWebSafeConfig ΒΆ
func NewWebSafeConfig() *EncodeConfig
NewWebSafeConfig creates a configuration for web-safe JSON
func (*EncodeConfig) Clone ΒΆ
func (c *EncodeConfig) Clone() *EncodeConfig
Clone creates a deep copy of the EncodeConfig
type Encoder ΒΆ
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes JSON values to an output stream. This type is fully compatible with encoding/json.Encoder.
func NewEncoder ΒΆ
NewEncoder returns a new encoder that writes to w. This function is fully compatible with encoding/json.NewEncoder.
func (*Encoder) Encode ΒΆ
Encode writes the JSON encoding of v to the stream, followed by a newline character.
See the documentation for Marshal for details about the conversion of Go values to JSON.
func (*Encoder) SetEscapeHTML ΒΆ
SetEscapeHTML specifies whether problematic HTML characters should be escaped inside JSON quoted strings. The default behavior is to escape &, <, and > to \u0026, \u003c, and \u003e to avoid certain safety problems that can arise when embedding JSON in HTML.
In non-HTML settings where the escaping interferes with the readability of the output, SetEscapeHTML(false) disables this behavior.
type ErrorClassifier ΒΆ added in v1.0.6
type ErrorClassifier struct{}
ErrorClassifier provides error classification for better error handling
func NewErrorClassifier ΒΆ added in v1.0.6
func NewErrorClassifier() *ErrorClassifier
NewErrorClassifier creates a new error classifier
func (*ErrorClassifier) GetErrorSuggestion ΒΆ added in v1.0.6
func (ec *ErrorClassifier) GetErrorSuggestion(err error) string
GetErrorSuggestion provides suggestions for common errors
func (*ErrorClassifier) IsRetryable ΒΆ added in v1.0.6
func (ec *ErrorClassifier) IsRetryable(err error) bool
IsRetryable determines if an error is retryable
func (*ErrorClassifier) IsSecurityRelated ΒΆ added in v1.0.7
func (ec *ErrorClassifier) IsSecurityRelated(err error) bool
IsSecurityRelated determines if an error is security-related
func (*ErrorClassifier) IsUserError ΒΆ added in v1.0.6
func (ec *ErrorClassifier) IsUserError(err error) bool
IsUserError determines if an error is caused by user input
type ExtractionContext ΒΆ
type ExtractionContext struct {
OriginalContainers []any // Original containers that hold the target arrays
ArrayFieldName string // Name of the array field being operated on
TargetIndices []int // Target indices for each container
OperationType string // Type of operation: "get", "set", "delete"
}
ExtractionContext holds context for distributed operations
type ExtractionGroup ΒΆ added in v1.0.8
type ExtractionGroup struct {
Segments []PathSegment
}
ExtractionGroup represents a group of consecutive extraction operations
type HealthStatus ΒΆ
type HealthStatus struct {
Timestamp time.Time `json:"timestamp"`
Healthy bool `json:"healthy"`
Checks map[string]CheckResult `json:"checks"`
}
HealthStatus represents the health status of the processor
type InvalidUnmarshalError ΒΆ
InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidUnmarshalError) Error ΒΆ
func (e *InvalidUnmarshalError) Error() string
type IterableValue ΒΆ
type IterableValue struct {
// contains filtered or unexported fields
}
IterableValue wraps a value to provide convenient access methods
func NewIterableValueWithIterator ΒΆ
func NewIterableValueWithIterator(data any, processor *Processor, iterator *Iterator) *IterableValue
NewIterableValueWithIterator creates an IterableValue with an iterator
func (*IterableValue) Exists ΒΆ
func (iv *IterableValue) Exists(key string) bool
Exists checks if a key or path exists in the object Supports path navigation with dot notation and array indices
func (*IterableValue) ForeachNested ΒΆ
func (iv *IterableValue) ForeachNested(path string, fn func(key any, item *IterableValue))
ForeachNested iterates over nested JSON structures with a path
func (*IterableValue) Get ΒΆ
func (iv *IterableValue) Get(path string) any
Get returns a value by path (supports dot notation and array indices)
func (*IterableValue) GetArray ΒΆ
func (iv *IterableValue) GetArray(key string) []any
GetArray returns an array value by key or path Supports path navigation with dot notation and array indices
func (*IterableValue) GetBool ΒΆ
func (iv *IterableValue) GetBool(key string) bool
GetBool returns a bool value by key or path Supports path navigation with dot notation and array indices
func (*IterableValue) GetBoolWithDefault ΒΆ
func (iv *IterableValue) GetBoolWithDefault(key string, defaultValue bool) bool
GetBoolWithDefault returns a bool value by key or path with a default fallback Supports path navigation with dot notation and array indices
func (*IterableValue) GetFloat64 ΒΆ
func (iv *IterableValue) GetFloat64(key string) float64
GetFloat64 returns a float64 value by key or path Supports path navigation with dot notation and array indices
func (*IterableValue) GetFloat64WithDefault ΒΆ
func (iv *IterableValue) GetFloat64WithDefault(key string, defaultValue float64) float64
GetFloat64WithDefault returns a float64 value by key or path with a default fallback Supports path navigation with dot notation and array indices
func (*IterableValue) GetInt ΒΆ
func (iv *IterableValue) GetInt(key string) int
GetInt returns an int value by key or path Supports path navigation with dot notation and array indices (e.g., "user.age" or "users[0].id")
func (*IterableValue) GetIntWithDefault ΒΆ
func (iv *IterableValue) GetIntWithDefault(key string, defaultValue int) int
GetIntWithDefault returns an int value by key or path with a default fallback Supports path navigation with dot notation and array indices
func (*IterableValue) GetObject ΒΆ
func (iv *IterableValue) GetObject(key string) map[string]any
GetObject returns an object value by key or path Supports path navigation with dot notation and array indices
func (*IterableValue) GetString ΒΆ
func (iv *IterableValue) GetString(key string) string
GetString returns a string value by key or path Supports path navigation with dot notation and array indices (e.g., "user.address.city" or "users[0].name")
func (*IterableValue) GetStringWithDefault ΒΆ
func (iv *IterableValue) GetStringWithDefault(key string, defaultValue string) string
GetStringWithDefault returns a string value by key or path with a default fallback Supports path navigation with dot notation and array indices
func (*IterableValue) GetWithDefault ΒΆ
func (iv *IterableValue) GetWithDefault(key string, defaultValue any) any
GetWithDefault returns a value by key or path with a default fallback Supports path navigation with dot notation and array indices
func (*IterableValue) IsEmpty ΒΆ
func (iv *IterableValue) IsEmpty(key string) bool
IsEmpty checks if a specific key's or path's value is empty Supports path navigation with dot notation and array indices
func (*IterableValue) IsEmptyData ΒΆ added in v1.0.8
func (iv *IterableValue) IsEmptyData() bool
IsEmptyData checks if the whole value is empty (for backward compatibility)
func (*IterableValue) IsNull ΒΆ
func (iv *IterableValue) IsNull(key string) bool
IsNull checks if a specific key's or path's value is null Supports path navigation with dot notation and array indices
func (*IterableValue) IsNullData ΒΆ added in v1.0.8
func (iv *IterableValue) IsNullData() bool
IsNullData checks if the whole value is null (for backward compatibility)
type Iterator ΒΆ
type Iterator struct {
// contains filtered or unexported fields
}
Iterator represents an iterator over JSON data
func NewIterator ΒΆ
func NewIterator(processor *Processor, data any, opts *ProcessorOptions) *Iterator
NewIterator creates a new Iterator
type IteratorControl ΒΆ
type IteratorControl int
IteratorControl represents control flags for iteration
const ( IteratorNormal IteratorControl = iota IteratorContinue IteratorBreak )
type JsonsError ΒΆ
type JsonsError struct {
Op string `json:"op"` // Operation that failed
Path string `json:"path"` // JSON path where error occurred
Message string `json:"message"` // Human-readable error message
Err error `json:"err"` // Underlying error
}
JsonsError represents a JSON processing error with essential context
func (*JsonsError) Error ΒΆ
func (e *JsonsError) Error() string
func (*JsonsError) Is ΒΆ
func (e *JsonsError) Is(target error) bool
Is implements error matching for Go 1.13+ error handling
func (*JsonsError) Unwrap ΒΆ
func (e *JsonsError) Unwrap() error
Unwrap returns the underlying error for error chain support
type Marshaler ΒΆ
Marshaler is the interface implemented by types that can marshal themselves into valid JSON.
type MarshalerError ΒΆ
type MarshalerError struct {
Type reflect.Type
Err error
// contains filtered or unexported fields
}
MarshalerError represents an error from calling a MarshalJSON or MarshalText method.
func (*MarshalerError) Error ΒΆ
func (e *MarshalerError) Error() string
func (*MarshalerError) Unwrap ΒΆ
func (e *MarshalerError) Unwrap() error
type MemoryTracker ΒΆ
type MemoryTracker struct {
// contains filtered or unexported fields
}
MemoryTracker tracks memory usage during tests
func NewMemoryTracker ΒΆ
func NewMemoryTracker(name string) *MemoryTracker
NewMemoryTracker creates a new memory tracker
func (*MemoryTracker) Report ΒΆ
func (mt *MemoryTracker) Report(t *testing.T)
Report reports memory usage
type MetricsCollector ΒΆ
type MetricsCollector interface {
RecordOperation(duration time.Duration, success bool, cacheHit int)
RecordCacheHit()
RecordCacheMiss()
StartConcurrentOperation()
EndConcurrentOperation()
GetStats() map[string]any
}
MetricsCollector interface for collecting metrics
type NavigationResult ΒΆ
type NavigationResult struct {
}
NavigationResult represents the result of a navigation operation
type Number ΒΆ
type Number string
Number represents a JSON number literal.
type NumberPreservingDecoder ΒΆ
type NumberPreservingDecoder struct {
// contains filtered or unexported fields
}
NumberPreservingDecoder provides JSON decoding with optimized number format preservation
func NewNumberPreservingDecoder ΒΆ
func NewNumberPreservingDecoder(preserveNumbers bool) *NumberPreservingDecoder
NewNumberPreservingDecoder creates a new decoder with performance and number preservation
func (*NumberPreservingDecoder) DecodeToAny ΒΆ
func (d *NumberPreservingDecoder) DecodeToAny(jsonStr string) (any, error)
DecodeToAny decodes JSON string to any type with performance and number preservation
type NumberPreservingValue ΒΆ
type NumberPreservingValue struct {
Value any `json:"value"`
Original string `json:"original,omitempty"`
}
NumberPreservingValue wraps a value with its original string representation
func (NumberPreservingValue) IsNumber ΒΆ
func (npv NumberPreservingValue) IsNumber() bool
IsNumber checks if the value represents a number
func (NumberPreservingValue) String ΒΆ
func (npv NumberPreservingValue) String() string
String returns the string representation, preferring original if available
func (NumberPreservingValue) ToFloat64 ΒΆ
func (npv NumberPreservingValue) ToFloat64() (float64, error)
ToFloat64 converts the value to float64 if possible
func (NumberPreservingValue) ToInt ΒΆ
func (npv NumberPreservingValue) ToInt() (int, error)
ToInt converts the value to int if possible
type OperationContext ΒΆ
type OperationContext struct {
Context context.Context
Operation Operation
Path string
Value any
Options *ProcessorOptions
StartTime time.Time
CreatePaths bool
}
OperationContext contains context information for operations
type PathInfo ΒΆ
type PathInfo struct {
Segments []PathSegment `json:"segments"`
IsPointer bool `json:"is_pointer"`
OriginalPath string `json:"original_path"`
}
PathInfo contains parsed path information
type PathSegment ΒΆ
type PathSegment = internal.PathSegment
PathSegment represents a parsed path segment with its type and value This is an alias to the internal PathSegment for backward compatibility
type PathSegmentInfo ΒΆ
type PathSegmentInfo struct {
Type string
Value string
Key string
Index int
Start *int
End *int
Step *int
Extract string
IsFlat bool
}
PathSegmentInfo contains information about a parsed path segment
type Processor ΒΆ
type Processor struct {
// contains filtered or unexported fields
}
Processor is the main JSON processing engine with thread safety and performance optimization
func New ΒΆ
New creates a new JSON processor with optimized configuration. If no configuration is provided, uses default configuration. This function follows the explicit config pattern as required by the design guidelines.
func (*Processor) Compact ΒΆ
func (p *Processor) Compact(jsonStr string, opts ...*ProcessorOptions) (string, error)
Compact removes whitespace from JSON string
func (*Processor) Delete ΒΆ
func (p *Processor) Delete(jsonStr, path string, opts ...*ProcessorOptions) (string, error)
Delete removes a value from JSON at the specified path
func (*Processor) EncodeBatch ΒΆ
func (p *Processor) EncodeBatch(pairs map[string]any, pretty bool, opts ...*ProcessorOptions) (string, error)
EncodeBatch encodes multiple key-value pairs as a JSON object
func (*Processor) EncodeFields ΒΆ
func (p *Processor) EncodeFields(value any, fields []string, pretty bool, opts ...*ProcessorOptions) (string, error)
EncodeFields encodes struct fields selectively based on field names
func (*Processor) EncodeStream ΒΆ
func (p *Processor) EncodeStream(values any, pretty bool, opts ...*ProcessorOptions) (string, error)
EncodeStream encodes multiple values as a JSON array stream
func (*Processor) EncodeStreamWithOptions ΒΆ
func (p *Processor) EncodeStreamWithOptions(values any, encOpts *EncodeConfig, opts ...*ProcessorOptions) (string, error)
EncodeStreamWithOptions encodes multiple values as a JSON array stream with advanced options
func (*Processor) EncodeWithConfig ΒΆ
func (p *Processor) EncodeWithConfig(value any, config *EncodeConfig, opts ...*ProcessorOptions) (string, error)
EncodeWithConfig converts any Go value to JSON string with full configuration control
func (*Processor) EncodeWithOptions ΒΆ
func (p *Processor) EncodeWithOptions(value any, encOpts *EncodeConfig, opts ...*ProcessorOptions) (string, error)
EncodeWithOptions converts any Go value to JSON string with advanced options
func (*Processor) EncodeWithTags ΒΆ
func (p *Processor) EncodeWithTags(value any, pretty bool, opts ...*ProcessorOptions) (string, error)
EncodeWithTags encodes struct with custom JSON tags handling
func (*Processor) Foreach ΒΆ
func (p *Processor) Foreach(jsonStr string, fn func(key any, item *IterableValue))
Foreach iterates over JSON arrays or objects using this processor
func (*Processor) ForeachNested ΒΆ added in v1.0.9
func (p *Processor) ForeachNested(jsonStr string, fn func(key any, item *IterableValue))
ForeachNested recursively iterates over all nested JSON structures This method traverses through all nested objects and arrays
func (*Processor) ForeachReturn ΒΆ
func (p *Processor) ForeachReturn(jsonStr string, fn func(key any, item *IterableValue)) (string, error)
ForeachReturn iterates over JSON arrays or objects and returns the JSON string This is useful for iteration with transformation purposes
func (*Processor) ForeachWithPath ΒΆ
func (p *Processor) ForeachWithPath(jsonStr, path string, fn func(key any, item *IterableValue)) error
ForeachWithPath iterates over JSON arrays or objects at a specific path using this processor This allows using custom processor configurations (security limits, nesting depth, etc.)
func (*Processor) ForeachWithPathAndControl ΒΆ added in v1.0.9
func (p *Processor) ForeachWithPathAndControl(jsonStr, path string, fn func(key any, value any) IteratorControl) error
ForeachWithPathAndControl iterates with control over iteration flow
func (*Processor) ForeachWithPathAndIterator ΒΆ added in v1.0.9
func (p *Processor) ForeachWithPathAndIterator(jsonStr, path string, fn func(key any, item *IterableValue, currentPath string) IteratorControl) error
ForeachWithPathAndIterator iterates over JSON at a path with path information
func (*Processor) FormatPretty ΒΆ
func (p *Processor) FormatPretty(jsonStr string, opts ...*ProcessorOptions) (string, error)
FormatPretty formats JSON string with indentation
func (*Processor) Get ΒΆ
func (p *Processor) Get(jsonStr, path string, opts ...*ProcessorOptions) (any, error)
Get retrieves a value from JSON using a path expression with performance
func (*Processor) GetHealthStatus ΒΆ
func (p *Processor) GetHealthStatus() HealthStatus
GetHealthStatus returns the current health status
func (*Processor) GetMultiple ΒΆ
func (p *Processor) GetMultiple(jsonStr string, paths []string, opts ...*ProcessorOptions) (map[string]any, error)
GetMultiple retrieves multiple values from JSON using multiple path expressions
func (*Processor) LoadFromFile ΒΆ
func (p *Processor) LoadFromFile(filePath string, opts ...*ProcessorOptions) (any, error)
LoadFromFile loads JSON data from a file
func (*Processor) LoadFromReader ΒΆ
LoadFromReader loads JSON data from an io.Reader with size limits
func (*Processor) Marshal ΒΆ
func (p *Processor) Marshal(value any, opts ...*ProcessorOptions) ([]byte, error)
Marshal converts any Go value to JSON bytes (similar to json.Marshal)
func (*Processor) MarshalIndent ΒΆ
func (p *Processor) MarshalIndent(value any, prefix, indent string, opts ...*ProcessorOptions) ([]byte, error)
MarshalIndent converts any Go value to indented JSON bytes (similar to json.MarshalIndent)
func (*Processor) MarshalToFile ΒΆ added in v1.0.6
MarshalToFile converts data to JSON and saves it to the specified file. This method provides the same functionality as the package-level MarshalToFile but with processor-specific configuration.
Parameters:
- path: file path where JSON will be saved (directories are created automatically)
- data: any Go value to be marshaled to JSON
- pretty: optional parameter - true for formatted JSON, false for compact (default: false)
Returns error if marshaling fails or file cannot be written.
func (*Processor) Parse ΒΆ
func (p *Processor) Parse(jsonStr string, target any, opts ...*ProcessorOptions) error
Parse parses a JSON string into the provided target with improved error handling
func (*Processor) ProcessBatch ΒΆ
func (p *Processor) ProcessBatch(operations []BatchOperation, opts ...*ProcessorOptions) ([]BatchResult, error)
ProcessBatch processes multiple operations in a single batch
func (*Processor) SafeGet ΒΆ
func (p *Processor) SafeGet(jsonStr, path string) TypeSafeAccessResult
SafeGet performs a type-safe get operation with comprehensive error handling
func (*Processor) SaveToFile ΒΆ
SaveToFile saves data to a JSON file with automatic directory creation Parameters:
- filePath: file path and name, creates directories if they don't exist
- data: JSON data to save
- pretty: optional parameter - true for formatted JSON, false for compact JSON (default: false)
func (*Processor) SaveToWriter ΒΆ
func (p *Processor) SaveToWriter(writer io.Writer, data any, pretty bool, opts ...*ProcessorOptions) error
SaveToWriter saves data to an io.Writer
func (*Processor) Set ΒΆ
Set sets a value in JSON at the specified path Returns:
- On success: modified JSON string and nil error
- On failure: original unmodified JSON string and error information
func (*Processor) SetMultiple ΒΆ
func (p *Processor) SetMultiple(jsonStr string, updates map[string]any, opts ...*ProcessorOptions) (string, error)
SetMultiple sets multiple values in JSON using a map of path-value pairs Returns:
- On success: modified JSON string and nil error
- On failure: original unmodified JSON string and error information
func (*Processor) ToJsonString ΒΆ
func (p *Processor) ToJsonString(value any, opts ...*ProcessorOptions) (string, error)
ToJsonString converts any Go value to JSON string with HTML escaping (safe for web)
func (*Processor) ToJsonStringPretty ΒΆ
func (p *Processor) ToJsonStringPretty(value any, opts ...*ProcessorOptions) (string, error)
ToJsonStringPretty converts any Go value to pretty JSON string with HTML escaping
func (*Processor) ToJsonStringStandard ΒΆ
func (p *Processor) ToJsonStringStandard(value any, opts ...*ProcessorOptions) (string, error)
ToJsonStringStandard converts any Go value to compact JSON string without HTML escaping
func (*Processor) Unmarshal ΒΆ
func (p *Processor) Unmarshal(data []byte, v any, opts ...*ProcessorOptions) error
Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. This method is fully compatible with encoding/json.Unmarshal.
func (*Processor) UnmarshalFromFile ΒΆ added in v1.0.6
func (p *Processor) UnmarshalFromFile(path string, v any, opts ...*ProcessorOptions) error
UnmarshalFromFile reads JSON data from the specified file and unmarshals it into the provided value. This method provides the same functionality as the package-level UnmarshalFromFile but with processor-specific configuration.
Parameters:
- path: file path to read JSON from
- v: pointer to the value where JSON will be unmarshaled
- opts: optional processor options for unmarshaling
Returns error if file cannot be read or JSON unmarshaling fails.
func (*Processor) Valid ΒΆ
func (p *Processor) Valid(jsonStr string, opts ...*ProcessorOptions) (bool, error)
Valid validates JSON format without parsing the entire structure
func (*Processor) ValidateSchema ΒΆ
func (p *Processor) ValidateSchema(jsonStr string, schema *Schema, opts ...*ProcessorOptions) ([]ValidationError, error)
ValidateSchema validates JSON data against a schema
func (*Processor) WarmupCache ΒΆ
func (p *Processor) WarmupCache(jsonStr string, paths []string, opts ...*ProcessorOptions) (*WarmupResult, error)
WarmupCache pre-loads commonly used paths into cache to improve first-access performance
type ProcessorCache ΒΆ
type ProcessorCache interface {
Get(key CacheKey) (any, bool)
Set(key CacheKey, value any, ttl time.Duration)
Clear()
Size() int
}
ProcessorCache interface for caching operations
type ProcessorConfig ΒΆ
type ProcessorConfig struct {
EnableCache bool
EnableMetrics bool
MaxConcurrency int
Timeout time.Duration
RateLimitEnabled bool
RateLimitRPS int
MaxDepth int
MaxPathLength int
}
ProcessorConfig holds configuration for the processor
func DefaultProcessorConfig ΒΆ
func DefaultProcessorConfig() *ProcessorConfig
DefaultProcessorConfig returns a default configuration
type ProcessorConfigAdapter ΒΆ added in v1.0.6
type ProcessorConfigAdapter struct {
// contains filtered or unexported fields
}
ProcessorConfigAdapter adapts ProcessorConfig to implement internal.ConfigInterface
func NewProcessorConfigAdapter ΒΆ added in v1.0.6
func NewProcessorConfigAdapter(config *ProcessorConfig) *ProcessorConfigAdapter
NewProcessorConfigAdapter creates a new adapter
func (*ProcessorConfigAdapter) AllowComments ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) AllowComments() bool
func (*ProcessorConfigAdapter) GetCacheTTL ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) GetCacheTTL() time.Duration
func (*ProcessorConfigAdapter) GetMaxCacheSize ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) GetMaxCacheSize() int
func (*ProcessorConfigAdapter) GetMaxConcurrency ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) GetMaxConcurrency() int
func (*ProcessorConfigAdapter) GetMaxJSONSize ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) GetMaxJSONSize() int64
Performance configuration
func (*ProcessorConfigAdapter) GetMaxNestingDepth ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) GetMaxNestingDepth() int
func (*ProcessorConfigAdapter) GetMaxPathDepth ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) GetMaxPathDepth() int
func (*ProcessorConfigAdapter) IsCacheEnabled ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) IsCacheEnabled() bool
Cache configuration
func (*ProcessorConfigAdapter) IsHealthCheckEnabled ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) IsHealthCheckEnabled() bool
func (*ProcessorConfigAdapter) IsMetricsEnabled ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) IsMetricsEnabled() bool
func (*ProcessorConfigAdapter) IsStrictMode ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) IsStrictMode() bool
Parsing configuration
func (*ProcessorConfigAdapter) PreserveNumbers ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) PreserveNumbers() bool
func (*ProcessorConfigAdapter) ShouldCleanupNulls ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) ShouldCleanupNulls() bool
func (*ProcessorConfigAdapter) ShouldCompactArrays ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) ShouldCompactArrays() bool
func (*ProcessorConfigAdapter) ShouldCreatePaths ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) ShouldCreatePaths() bool
Operation configuration
func (*ProcessorConfigAdapter) ShouldValidateFilePath ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) ShouldValidateFilePath() bool
func (*ProcessorConfigAdapter) ShouldValidateInput ΒΆ added in v1.0.6
func (pca *ProcessorConfigAdapter) ShouldValidateInput() bool
Security configuration
type ProcessorMetrics ΒΆ
type ProcessorMetrics struct {
// Operation metrics
TotalOperations int64 `json:"total_operations"`
SuccessfulOperations int64 `json:"successful_operations"`
FailedOperations int64 `json:"failed_operations"`
SuccessRate float64 `json:"success_rate"`
// Cache metrics
CacheHits int64 `json:"cache_hits"`
CacheMisses int64 `json:"cache_misses"`
CacheHitRate float64 `json:"cache_hit_rate"`
// Performance metrics
AverageProcessingTime time.Duration `json:"average_processing_time"`
MaxProcessingTime time.Duration `json:"max_processing_time"`
MinProcessingTime time.Duration `json:"min_processing_time"`
// Memory metrics
TotalMemoryAllocated int64 `json:"total_memory_allocated"`
PeakMemoryUsage int64 `json:"peak_memory_usage"`
CurrentMemoryUsage int64 `json:"current_memory_usage"`
// Concurrency metrics
ActiveConcurrentOps int64 `json:"active_concurrent_ops"`
MaxConcurrentOps int64 `json:"max_concurrent_ops"`
// contains filtered or unexported fields
}
ProcessorMetrics provides comprehensive processor performance metrics
type ProcessorOptions ΒΆ
type ProcessorOptions struct {
Context context.Context `json:"-"` // Context for cancellation and timeouts
CacheResults bool `json:"cache_results"` // Whether to cache results
StrictMode bool `json:"strict_mode"` // Enable strict mode for this operation
MaxDepth int `json:"max_depth"` // Maximum recursion depth
AllowComments bool `json:"allow_comments"` // Allow JSON with comments
PreserveNumbers bool `json:"preserve_numbers"` // Preserve number format (avoid scientific notation)
CreatePaths bool `json:"create_paths"` // Override global CreatePaths setting for this operation
CleanupNulls bool `json:"cleanup_nulls"` // Remove null values after deletion operations
CompactArrays bool `json:"compact_arrays"` // Remove all null values from arrays (not just trailing)
ContinueOnError bool `json:"continue_on_error"` // Continue processing other operations even if some fail (for batch operations)
}
ProcessorOptions provides per-operation configuration
func DefaultOptions ΒΆ
func DefaultOptions() *ProcessorOptions
DefaultOptions returns default processor options
func (*ProcessorOptions) Clone ΒΆ
func (opts *ProcessorOptions) Clone() *ProcessorOptions
Clone creates a deep copy of ProcessorOptions
type PropertyAccessResult ΒΆ
PropertyAccessResult represents the result of a property access operation
type RateLimiter ΒΆ
RateLimiter interface for rate limiting
type RecursiveProcessor ΒΆ
type RecursiveProcessor struct {
// contains filtered or unexported fields
}
RecursiveProcessor implements true recursive processing for all operations
func NewRecursiveProcessor ΒΆ
func NewRecursiveProcessor(p *Processor) *RecursiveProcessor
NewRecursiveProcessor creates a new unified recursive processor
func (*RecursiveProcessor) ProcessRecursively ΒΆ
func (urp *RecursiveProcessor) ProcessRecursively(data any, path string, operation Operation, value any) (any, error)
ProcessRecursively performs recursive processing for any operation
func (*RecursiveProcessor) ProcessRecursivelyWithOptions ΒΆ
func (urp *RecursiveProcessor) ProcessRecursivelyWithOptions(data any, path string, operation Operation, value any, createPaths bool) (any, error)
ProcessRecursivelyWithOptions performs recursive processing with path creation options
type ResourceManagerStats ΒΆ added in v1.0.6
type ResourceManagerStats struct {
AllocatedBuilders int64 `json:"allocated_builders"`
AllocatedSegments int64 `json:"allocated_segments"`
AllocatedBuffers int64 `json:"allocated_buffers"`
LastCleanup int64 `json:"last_cleanup"`
}
ResourceManagerStats provides statistics about resource usage
type ResourceMonitor ΒΆ
type ResourceMonitor struct {
// contains filtered or unexported fields
}
ResourceMonitor provides enhanced resource monitoring and leak detection
func NewResourceMonitor ΒΆ
func NewResourceMonitor() *ResourceMonitor
NewResourceMonitor creates a new resource monitor
func (*ResourceMonitor) CheckForLeaks ΒΆ
func (rm *ResourceMonitor) CheckForLeaks() []string
CheckForLeaks performs leak detection and returns potential issues
func (*ResourceMonitor) GetMemoryEfficiency ΒΆ
func (rm *ResourceMonitor) GetMemoryEfficiency() float64
GetMemoryEfficiency returns memory efficiency as a percentage (0-100)
func (*ResourceMonitor) GetPoolEfficiency ΒΆ
func (rm *ResourceMonitor) GetPoolEfficiency() float64
GetPoolEfficiency returns pool efficiency as a percentage (0-100)
func (*ResourceMonitor) GetStats ΒΆ
func (rm *ResourceMonitor) GetStats() ResourceStats
GetStats returns current resource statistics
func (*ResourceMonitor) RecordAllocation ΒΆ
func (rm *ResourceMonitor) RecordAllocation(bytes int64)
RecordAllocation records memory allocation
func (*ResourceMonitor) RecordDeallocation ΒΆ
func (rm *ResourceMonitor) RecordDeallocation(bytes int64)
RecordDeallocation records memory deallocation
func (*ResourceMonitor) RecordOperation ΒΆ
func (rm *ResourceMonitor) RecordOperation(duration time.Duration)
RecordOperation records an operation with timing
func (*ResourceMonitor) RecordPoolEviction ΒΆ
func (rm *ResourceMonitor) RecordPoolEviction()
RecordPoolEviction records a pool eviction
func (*ResourceMonitor) RecordPoolHit ΒΆ
func (rm *ResourceMonitor) RecordPoolHit()
RecordPoolHit records a pool cache hit
func (*ResourceMonitor) RecordPoolMiss ΒΆ
func (rm *ResourceMonitor) RecordPoolMiss()
RecordPoolMiss records a pool cache miss
type ResourcePoolStats ΒΆ
type ResourcePoolStats struct {
StringBuilderPoolActive bool `json:"string_builder_pool_active"` // Whether string builder pool is active
PathSegmentPoolActive bool `json:"path_segment_pool_active"` // Whether path segment pool is active
}
ResourcePoolStats provides statistics about resource pools
type ResourceStats ΒΆ
type ResourceStats struct {
AllocatedBytes int64 // Total allocated bytes
FreedBytes int64 // Total freed bytes
PeakMemoryUsage int64 // Peak memory usage
PoolHits int64 // Pool cache hits
PoolMisses int64 // Pool cache misses
PoolEvictions int64 // Pool evictions
MaxGoroutines int64 // Maximum goroutines seen
CurrentGoroutines int64 // Current goroutine count
AvgResponseTime time.Duration // Average response time
TotalOperations int64 // Total operations processed
}
ResourceStats represents resource usage statistics
type RootDataTypeConversionError ΒΆ
RootDataTypeConversionError represents an error that signals root data type conversion is needed
func (*RootDataTypeConversionError) Error ΒΆ
func (e *RootDataTypeConversionError) Error() string
type Schema ΒΆ
type Schema struct {
Type string `json:"type,omitempty"`
Properties map[string]*Schema `json:"properties,omitempty"`
Items *Schema `json:"items,omitempty"`
Required []string `json:"required,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"`
Format string `json:"format,omitempty"`
AdditionalProperties bool `json:"additionalProperties,omitempty"`
// Enhanced validation options
MinItems int `json:"minItems,omitempty"` // Minimum array items
MaxItems int `json:"maxItems,omitempty"` // Maximum array items
UniqueItems bool `json:"uniqueItems,omitempty"` // Array items must be unique
Enum []any `json:"enum,omitempty"` // Allowed values
Const any `json:"const,omitempty"` // Constant value
MultipleOf float64 `json:"multipleOf,omitempty"` // Number must be multiple of this
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"` // Minimum is exclusive
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"` // Maximum is exclusive
Title string `json:"title,omitempty"` // Schema title
Description string `json:"description,omitempty"` // Schema description
Default any `json:"default,omitempty"` // Default value
Examples []any `json:"examples,omitempty"` // Example values
// contains filtered or unexported fields
}
Schema represents a JSON schema for validation
func DefaultSchema ΒΆ
func DefaultSchema() *Schema
DefaultSchema returns a default schema configuration
func (*Schema) HasMaxItems ΒΆ
HasMaxItems returns true if MaxItems constraint is explicitly set
func (*Schema) HasMaxLength ΒΆ
HasMaxLength returns true if MaxLength constraint is explicitly set
func (*Schema) HasMaximum ΒΆ
HasMaximum returns true if Maximum constraint is explicitly set
func (*Schema) HasMinItems ΒΆ
HasMinItems returns true if MinItems constraint is explicitly set
func (*Schema) HasMinLength ΒΆ
HasMinLength returns true if MinLength constraint is explicitly set
func (*Schema) HasMinimum ΒΆ
HasMinimum returns true if Minimum constraint is explicitly set
func (*Schema) SetExclusiveMaximum ΒΆ
SetExclusiveMaximum sets the exclusive maximum flag
func (*Schema) SetExclusiveMinimum ΒΆ
SetExclusiveMinimum sets the exclusive minimum flag
func (*Schema) SetMaxItems ΒΆ
SetMaxItems sets the maximum items constraint for arrays
func (*Schema) SetMaxLength ΒΆ
SetMaxLength sets the maximum length constraint
func (*Schema) SetMaximum ΒΆ
SetMaximum sets the maximum value constraint
func (*Schema) SetMinItems ΒΆ
SetMinItems sets the minimum items constraint for arrays
func (*Schema) SetMinLength ΒΆ
SetMinLength sets the minimum length constraint
func (*Schema) SetMinimum ΒΆ
SetMinimum sets the minimum value constraint
type SecurityValidator ΒΆ added in v1.0.6
type SecurityValidator struct {
// contains filtered or unexported fields
}
SecurityValidator provides comprehensive security validation for JSON processing This consolidates all validation logic in one place for better maintainability
func NewSecurityValidator ΒΆ added in v1.0.6
func NewSecurityValidator(maxJSONSize int64, maxPathLength, maxNestingDepth int) *SecurityValidator
NewSecurityValidator creates a new security validator with the given limits
func (*SecurityValidator) ValidateAll ΒΆ added in v1.0.7
func (sv *SecurityValidator) ValidateAll(jsonStr, path string) error
ValidateAll performs comprehensive validation of both JSON and path inputs
func (*SecurityValidator) ValidateJSONInput ΒΆ added in v1.0.6
func (sv *SecurityValidator) ValidateJSONInput(jsonStr string) error
ValidateJSONInput performs comprehensive JSON input validation with enhanced security
func (*SecurityValidator) ValidatePathInput ΒΆ added in v1.0.6
func (sv *SecurityValidator) ValidatePathInput(path string) error
ValidatePathInput performs comprehensive path validation with enhanced security
type ShardStats ΒΆ
type ShardStats struct {
Size int64 `json:"size"` // Number of entries in shard
Memory int64 `json:"memory"` // Memory usage of shard in bytes
}
ShardStats provides statistics for a single cache shard
type SimpleCacheImpl ΒΆ added in v1.0.6
type SimpleCacheImpl struct {
// contains filtered or unexported fields
}
SimpleCacheImpl implements ProcessorCache using internal.CacheManager
func NewSimpleCacheImpl ΒΆ added in v1.0.6
func NewSimpleCacheImpl(config internal.ConfigInterface) *SimpleCacheImpl
NewSimpleCacheImpl creates a new simple cache implementation
func (*SimpleCacheImpl) Clear ΒΆ added in v1.0.6
func (sc *SimpleCacheImpl) Clear()
Clear removes all entries from cache
func (*SimpleCacheImpl) Get ΒΆ added in v1.0.6
func (sc *SimpleCacheImpl) Get(key CacheKey) (any, bool)
Get retrieves a value from cache using CacheKey
func (*SimpleCacheImpl) Set ΒΆ added in v1.0.6
func (sc *SimpleCacheImpl) Set(key CacheKey, value any, ttl time.Duration)
Set stores a value in cache using CacheKey (ttl parameter is ignored as TTL is configured globally)
func (*SimpleCacheImpl) Size ΒΆ added in v1.0.6
func (sc *SimpleCacheImpl) Size() int
Size returns the number of entries in cache
type Stats ΒΆ
type Stats struct {
CacheSize int64 `json:"cache_size"` // Current cache size
CacheMemory int64 `json:"cache_memory"` // Cache memory usage in bytes
MaxCacheSize int `json:"max_cache_size"` // Maximum cache size
HitCount int64 `json:"hit_count"` // Cache hit count
MissCount int64 `json:"miss_count"` // Cache miss count
HitRatio float64 `json:"hit_ratio"` // Cache hit ratio
CacheTTL time.Duration `json:"cache_ttl"` // Cache TTL
CacheEnabled bool `json:"cache_enabled"` // Whether cache is enabled
IsClosed bool `json:"is_closed"` // Whether processor is closed
MemoryEfficiency float64 `json:"memory_efficiency"` // Memory efficiency (hits per MB)
OperationCount int64 `json:"operation_count"` // Total operations performed
ErrorCount int64 `json:"error_count"` // Total errors encountered
}
Stats provides processor performance statistics
type SyntaxError ΒΆ
type SyntaxError struct {
Offset int64 // error occurred after reading Offset bytes
// contains filtered or unexported fields
}
SyntaxError is a description of a JSON syntax error. Unmarshal will return a SyntaxError if the JSON can't be parsed.
func (*SyntaxError) Error ΒΆ
func (e *SyntaxError) Error() string
type TestDataGenerator ΒΆ
type TestDataGenerator struct {
// contains filtered or unexported fields
}
TestDataGenerator generates test data for various scenarios
func NewTestDataGenerator ΒΆ
func NewTestDataGenerator() *TestDataGenerator
NewTestDataGenerator creates a new test data generator
func (*TestDataGenerator) GenerateArrayJSON ΒΆ
func (g *TestDataGenerator) GenerateArrayJSON() string
GenerateArrayJSON generates JSON with various array structures
func (*TestDataGenerator) GenerateComplexJSON ΒΆ
func (g *TestDataGenerator) GenerateComplexJSON() string
GenerateComplexJSON generates complex nested JSON structures
func (*TestDataGenerator) GenerateInvalidJSON ΒΆ
func (g *TestDataGenerator) GenerateInvalidJSON() []string
GenerateInvalidJSON generates invalid JSON for error testing
func (*TestDataGenerator) GenerateSimpleJSON ΒΆ
func (g *TestDataGenerator) GenerateSimpleJSON() string
GenerateSimpleJSON generates simple JSON structures
type TestHelper ΒΆ
type TestHelper struct {
// contains filtered or unexported fields
}
TestHelper provides utilities for testing JSON operations
func NewTestHelper ΒΆ
func NewTestHelper(t *testing.T) *TestHelper
NewTestHelper creates a new test helper
func (*TestHelper) AssertEqual ΒΆ
func (h *TestHelper) AssertEqual(expected, actual any, msgAndArgs ...any)
AssertEqual checks if two values are equal
func (*TestHelper) AssertError ΒΆ
func (h *TestHelper) AssertError(err error, msgAndArgs ...any)
AssertError checks that error is not nil
func (*TestHelper) AssertErrorContains ΒΆ
func (h *TestHelper) AssertErrorContains(err error, contains string, msgAndArgs ...any)
AssertErrorContains checks that error contains specific text
func (*TestHelper) AssertFalse ΒΆ
func (h *TestHelper) AssertFalse(condition bool, msgAndArgs ...any)
AssertFalse checks that condition is false
func (*TestHelper) AssertNil ΒΆ
func (h *TestHelper) AssertNil(value any, msgAndArgs ...any)
AssertNil checks that value is nil
func (*TestHelper) AssertNoError ΒΆ
func (h *TestHelper) AssertNoError(err error, msgAndArgs ...any)
AssertNoError checks that error is nil
func (*TestHelper) AssertNoPanic ΒΆ
func (h *TestHelper) AssertNoPanic(fn func(), msgAndArgs ...any)
AssertNoPanic checks that function doesn't panic
func (*TestHelper) AssertNotEqual ΒΆ
func (h *TestHelper) AssertNotEqual(expected, actual any, msgAndArgs ...any)
AssertNotEqual checks if two values are not equal
func (*TestHelper) AssertNotNil ΒΆ
func (h *TestHelper) AssertNotNil(value any, msgAndArgs ...any)
AssertNotNil checks that value is not nil
func (*TestHelper) AssertPanic ΒΆ
func (h *TestHelper) AssertPanic(fn func(), msgAndArgs ...any)
AssertPanic checks that function panics
func (*TestHelper) AssertTrue ΒΆ
func (h *TestHelper) AssertTrue(condition bool, msgAndArgs ...any)
AssertTrue checks that condition is true
type TextMarshaler ΒΆ
TextMarshaler is the interface implemented by an object that can marshal itself into a textual form.
MarshalText encodes the receiver into UTF-8-encoded text and returns the result.
type TextUnmarshaler ΒΆ
TextUnmarshaler is the interface implemented by an object that can unmarshal a textual representation of itself.
UnmarshalText must be able to decode the form generated by MarshalText. UnmarshalText must copy the text if it wishes to retain the text after returning.
type Token ΒΆ
type Token any
Token holds a value of one of these types:
Delim, for the four JSON delimiters [ ] { }
bool, for JSON booleans
float64, for JSON numbers
Number, for JSON numbers
string, for JSON string literals
nil, for JSON null
type TypeSafeAccessResult ΒΆ
TypeSafeAccessResult represents the result of a type-safe access operation
func (TypeSafeAccessResult) AsBool ΒΆ
func (r TypeSafeAccessResult) AsBool() (bool, error)
AsBool safely converts the result to bool
func (TypeSafeAccessResult) AsInt ΒΆ
func (r TypeSafeAccessResult) AsInt() (int, error)
AsInt safely converts the result to int
func (TypeSafeAccessResult) AsString ΒΆ
func (r TypeSafeAccessResult) AsString() (string, error)
AsString safely converts the result to string
type TypeSafeResult ΒΆ
TypeSafeResult represents a type-safe operation result
func SafeGetTypedWithProcessor ΒΆ
func SafeGetTypedWithProcessor[T any](p *Processor, jsonStr, path string) TypeSafeResult[T]
SafeGetTypedWithProcessor performs a type-safe get operation with generic type constraints
func (TypeSafeResult[T]) Ok ΒΆ
func (r TypeSafeResult[T]) Ok() bool
Ok returns true if the result is valid (no error and exists)
func (TypeSafeResult[T]) Unwrap ΒΆ
func (r TypeSafeResult[T]) Unwrap() T
Unwrap returns the value or zero value if there's an error For panic behavior, use UnwrapOrPanic instead
func (TypeSafeResult[T]) UnwrapOr ΒΆ
func (r TypeSafeResult[T]) UnwrapOr(defaultValue T) T
UnwrapOr returns the value or the provided default if there's an error or value doesn't exist
func (TypeSafeResult[T]) UnwrapOrPanic ΒΆ added in v1.0.4
func (r TypeSafeResult[T]) UnwrapOrPanic() T
UnwrapOrPanic returns the value or panics if there's an error Use this only when you're certain the operation succeeded
type UnifiedResourceManager ΒΆ added in v1.0.6
type UnifiedResourceManager struct {
// contains filtered or unexported fields
}
UnifiedResourceManager consolidates all resource management for optimal performance
func NewUnifiedResourceManager ΒΆ added in v1.0.6
func NewUnifiedResourceManager() *UnifiedResourceManager
NewUnifiedResourceManager creates a new unified resource manager
func (*UnifiedResourceManager) GetBuffer ΒΆ added in v1.0.6
func (urm *UnifiedResourceManager) GetBuffer() []byte
GetBuffer retrieves a byte buffer from the pool (thread-safe)
func (*UnifiedResourceManager) GetPathSegments ΒΆ added in v1.0.6
func (urm *UnifiedResourceManager) GetPathSegments() []PathSegment
GetPathSegments retrieves a path segments slice from the pool (thread-safe)
func (*UnifiedResourceManager) GetStats ΒΆ added in v1.0.6
func (urm *UnifiedResourceManager) GetStats() ResourceManagerStats
GetStats returns resource usage statistics
func (*UnifiedResourceManager) GetStringBuilder ΒΆ added in v1.0.6
func (urm *UnifiedResourceManager) GetStringBuilder() *strings.Builder
GetStringBuilder retrieves a string builder from the pool (thread-safe)
func (*UnifiedResourceManager) PerformMaintenance ΒΆ added in v1.0.6
func (urm *UnifiedResourceManager) PerformMaintenance()
PerformMaintenance performs periodic cleanup and optimization (thread-safe)
func (*UnifiedResourceManager) PutBuffer ΒΆ added in v1.0.6
func (urm *UnifiedResourceManager) PutBuffer(buf []byte)
PutBuffer returns a byte buffer to the pool (thread-safe)
func (*UnifiedResourceManager) PutPathSegments ΒΆ added in v1.0.6
func (urm *UnifiedResourceManager) PutPathSegments(segments []PathSegment)
PutPathSegments returns a path segments slice to the pool (thread-safe)
func (*UnifiedResourceManager) PutStringBuilder ΒΆ added in v1.0.6
func (urm *UnifiedResourceManager) PutStringBuilder(sb *strings.Builder)
PutStringBuilder returns a string builder to the pool (thread-safe)
type UnmarshalTypeError ΒΆ
type UnmarshalTypeError struct {
Value string // description of JSON value - "bool", "array", "number -5"
Type reflect.Type // type of Go value it could not be assigned to
Offset int64 // error occurred after reading Offset bytes
Struct string // name of the root type containing the field
Field string // the full path from root node to the value
Err error // may be nil
}
UnmarshalTypeError describes a JSON value that was not appropriate for a value of a specific Go type.
func (*UnmarshalTypeError) Error ΒΆ
func (e *UnmarshalTypeError) Error() string
func (*UnmarshalTypeError) Unwrap ΒΆ
func (e *UnmarshalTypeError) Unwrap() error
type Unmarshaler ΒΆ
Unmarshaler is the interface implemented by types that can unmarshal a JSON description of themselves. The input can be assumed to be a valid encoding of a JSON value. UnmarshalJSON must copy the JSON data if it wishes to retain the data after returning.
By convention, to approximate the behavior of Unmarshal itself, Unmarshalers implement UnmarshalJSON([]byte("null")) as a no-op.
type UnsupportedTypeError ΒΆ
UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.
func (*UnsupportedTypeError) Error ΒΆ
func (e *UnsupportedTypeError) Error() string
type UnsupportedValueError ΒΆ
UnsupportedValueError is returned by Marshal when attempting to encode an unsupported value.
func (*UnsupportedValueError) Error ΒΆ
func (e *UnsupportedValueError) Error() string
type ValidationError ΒΆ
ValidationError represents a schema validation error
func ValidateSchema ΒΆ
func ValidateSchema(jsonStr string, schema *Schema, opts ...*ProcessorOptions) ([]ValidationError, error)
ValidateSchema validates JSON data against a schema
func (*ValidationError) Error ΒΆ
func (ve *ValidationError) Error() string
type Validator ΒΆ added in v1.0.6
type Validator struct {
// contains filtered or unexported fields
}
Validator provides streamlined input validation with enhanced security
func NewValidator ΒΆ added in v1.0.6
NewValidator creates a new validator with the given limits
func (*Validator) ValidateJSONInput ΒΆ added in v1.0.6
ValidateJSONInput performs comprehensive JSON input validation
func (*Validator) ValidatePathInput ΒΆ added in v1.0.6
ValidatePathInput performs comprehensive path validation
type WarmupResult ΒΆ
type WarmupResult struct {
TotalPaths int `json:"total_paths"` // Total number of paths processed
Successful int `json:"successful"` // Number of successfully warmed up paths
Failed int `json:"failed"` // Number of failed paths
SuccessRate float64 `json:"success_rate"` // Success rate as percentage (0-100)
FailedPaths []string `json:"failed_paths,omitempty"` // List of paths that failed (optional)
}
WarmupResult represents the result of a cache warmup operation