Documentation ¶
Index ¶
- Constants
- func Debug(message string)
- func EvalEndsWith(a, b *ValueNode) bool
- func EvalEqual(a, b *ValueNode) bool
- func EvalGreaterOrEqual(a, b *ValueNode) bool
- func EvalGreaterThan(a, b *ValueNode) bool
- func EvalIn(a, b *ValueNode) bool
- func EvalIncludes(a, b *ValueNode) bool
- func EvalLessThan(a, b *ValueNode) bool
- func EvalLessThanOrEqual(a, b *ValueNode) bool
- func EvalNotEquals(a, b *ValueNode) bool
- func EvalNotIn(a, b *ValueNode) bool
- func EvalStartsWith(a, b *ValueNode) bool
- func HashString(data string) uint64
- func IsObjectLike(value interface{}) bool
- type Almanac
- func (a *Almanac) AddEvent(event Event, outcome EventOutcome) error
- func (a *Almanac) AddFact(key string, value *Fact)
- func (a *Almanac) AddResult(ruleResult *RuleResult)
- func (a *Almanac) AddRuntimeFact(path string, value ValueNode) error
- func (a *Almanac) FactValue(path string) (*Fact, error)
- func (a *Almanac) GetEvents(outcome EventOutcome) *[]Event
- func (a *Almanac) GetResults() []RuleResult
- func (a *Almanac) GetValue(path string) (interface{}, error)
- type Condition
- func (c *Condition) Evaluate(almanac *Almanac, operatorMap map[string]Operator) (*EvaluationResult, error)
- func (c *Condition) IsBooleanOperator() bool
- func (c *Condition) IsConditionReference() bool
- func (c *Condition) ToJSON(stringify bool) (interface{}, error)
- func (c *Condition) UnmarshalJSON(data []byte) error
- func (c *Condition) Validate() error
- type ConditionMap
- type ConditionProperties
- type DataType
- type DynamicFactCallback
- type Engine
- func (e *Engine) AddCalculatedFact(path string, method DynamicFactCallback, options *FactOptions) error
- func (e *Engine) AddFact(path string, value *ValueNode, options *FactOptions) error
- func (e *Engine) AddOperator(operatorOrName interface{}, cb func(*ValueNode, *ValueNode) bool)
- func (e *Engine) AddRule(rule *Rule) error
- func (e *Engine) AddRuleFromMap(rp *RuleConfig) error
- func (e *Engine) AddRules(rules []*Rule) error
- func (e *Engine) EvaluateRules(rules []*Rule, almanac *Almanac, ctx *ExecutionContext) error
- func (e *Engine) GetFact(path string) *Fact
- func (e *Engine) GetRules() []*Rule
- func (e *Engine) PrioritizeRules() [][]*Rule
- func (e *Engine) RemoveCondition(name string) bool
- func (e *Engine) RemoveFact(path string) bool
- func (e *Engine) RemoveOperator(operatorOrName interface{}) bool
- func (e *Engine) RemoveRule(rule *Rule) bool
- func (e *Engine) RemoveRuleByName(name string) bool
- func (e *Engine) Run(ctx context.Context, input []byte) (map[string]interface{}, error)
- func (e *Engine) RunWithMap(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error)
- func (e *Engine) Stop() *Engine
- func (e *Engine) UpdateRule(r *Rule) error
- type EvaluationResult
- type Event
- type EventCallback
- type EventConfig
- type EventHandler
- type EventOutcome
- type ExecutionContext
- type Fact
- type FactMap
- type FactOptions
- type InvalidRuleError
- type Operator
- type Options
- type Rule
- func (r *Rule) Evaluate(ctx *ExecutionContext, almanac *Almanac) (*RuleResult, error)
- func (r *Rule) GetConditions() *Condition
- func (r *Rule) GetEngine() *Engine
- func (r *Rule) GetEvent() Event
- func (r *Rule) GetPriority() int
- func (r *Rule) SetEngine(engine *Engine)
- func (r *Rule) ToJSON(stringify bool) (interface{}, error)
- type RuleConfig
- type RuleEngineOptions
- type RuleProperties
- type RuleResult
- type TopLevelCondition
- type UndefinedFactError
- type ValueNode
- func (v *ValueNode) IsArray() bool
- func (v *ValueNode) IsBool() bool
- func (v *ValueNode) IsNull() bool
- func (v *ValueNode) IsNumber() bool
- func (v *ValueNode) IsObject() bool
- func (v *ValueNode) IsString() bool
- func (v *ValueNode) Raw() interface{}
- func (v *ValueNode) SameType(other *ValueNode) bool
- func (v *ValueNode) UnmarshalJSON(data []byte) error
Constants ¶
const ( READY = "READY" RUNNING = "RUNNING" FINISHED = "FINISHED" )
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(message string)
Debug logs the message if the DEBUG environment variable contains "json-rules-engine"
func EvalEndsWith ¶ added in v0.2.0
EvalEndsWith checks if the string in the first ValueNode ends with the string in the second ValueNode. Both 'a' and 'b' must be strings for the comparison to be valid. Returns true if 'a' ends with 'b', false otherwise.
func EvalEqual ¶ added in v0.2.0
EvalEqual checks if two ValueNode instances are equal. It compares their types first, and if they match, it evaluates their values. Supported types: String, Number, Bool, Array. Returns true if both nodes have the same type and value, false otherwise.
func EvalGreaterOrEqual ¶ added in v0.2.0
EvalGreaterOrEqual checks if the first ValueNode is greater than or equal to the second. Both 'a' and 'b' must be numbers for the comparison to be valid. Returns true if 'a' is greater than or equal to 'b', false otherwise.
func EvalGreaterThan ¶ added in v0.2.0
EvalGreaterThan checks if the first ValueNode is greater than the second. Both 'a' and 'b' must be numbers for the comparison to be valid. Returns true if 'a' is greater than 'b', false otherwise.
func EvalIn ¶ added in v0.2.0
EvalIn checks if a ValueNode instance is present in an array of ValueNode instances. It assumes that 'b' is an array and iterates through it to find a match with 'a'. Returns true if 'a' is found in 'b', false otherwise.
func EvalIncludes ¶ added in v0.2.0
EvalIncludes checks if the string in the first ValueNode contains with the string in the second ValueNode. Both 'a' and 'b' must be strings for the comparison to be valid. Returns true if 'a' ends with 'b', false otherwise.
func EvalLessThan ¶ added in v0.2.0
EvalLessThan checks if the first ValueNode is less than the second. Both 'a' and 'b' must be numbers for the comparison to be valid. Returns true if 'a' is less than 'b', false otherwise.
func EvalLessThanOrEqual ¶ added in v0.2.0
EvalLessThanOrEqual checks if the first ValueNode is less than or equal to the second. Both 'a' and 'b' must be numbers for the comparison to be valid. Returns true if 'a' is less than or equal to 'b', false otherwise.
func EvalNotEquals ¶ added in v0.2.0
EvalNotEquals checks if two ValueNode instances are not equal. It returns the negation of the EvalEqual function. Returns true if the nodes are not equal, false otherwise.
func EvalNotIn ¶ added in v0.2.0
EvalNotIn checks if a ValueNode instance is not present in an array of ValueNode instances. It returns the negation of EvalIn. Returns true if 'a' is not found in 'b', false otherwise.
func EvalStartsWith ¶ added in v0.2.0
EvalStartsWith checks if the string in the first ValueNode starts with the string in the second ValueNode. Both 'a' and 'b' must be strings for the comparison to be valid. Returns true if 'a' starts with 'b', false otherwise.
func HashString ¶ added in v0.2.0
func IsObjectLike ¶
func IsObjectLike(value interface{}) bool
isObjectLike checks if the value is an object-like structure
Types ¶
type Almanac ¶
type Almanac struct {
// contains filtered or unexported fields
}
Almanac is a struct that manages fact results lookup and caching within a rules engine. It allows storing raw facts, caching results of rules, and logging events (success/failure). The Almanac plays a key role in the rules engine by allowing rules to evaluate facts efficiently.
func NewAlmanac ¶
NewAlmanac creates and returns a new Almanac instance. Params: - rf: Raw facts in the form of a gjson.Result. - options: Custom settings such as allowing undefined facts. - initialCapacity: The initial capacity to allocate for rule results. Returns a pointer to a new Almanac.
func (*Almanac) AddEvent ¶
func (a *Almanac) AddEvent(event Event, outcome EventOutcome) error
AddEvent logs an event in the Almanac, marking it as either a success or failure. Params: - event: The event to be added. - outcome: The outcome of the event ("success" or "failure"). Returns an error if the outcome is invalid.
func (*Almanac) AddResult ¶
func (a *Almanac) AddResult(ruleResult *RuleResult)
AddResult adds a rule evaluation result to the Almanac. This function stores the result of a rule once it has been evaluated.
func (*Almanac) AddRuntimeFact ¶
AddRuntimeFact adds a constant fact during runtime
func (*Almanac) GetEvents ¶
func (a *Almanac) GetEvents(outcome EventOutcome) *[]Event
GetEvents retrieves events logged in the Almanac based on the specified outcome. If the outcome is "success" or "failure", it returns the events for that outcome. If the outcome is an empty string, it returns all events (success and failure combined). Params: - outcome: The desired outcome ("success", "failure", or empty string for all events). Returns a pointer to a slice of events for the specified outcome.
func (*Almanac) GetResults ¶
func (a *Almanac) GetResults() []RuleResult
GetResults retrieves all rule results
type Condition ¶
type Condition struct { Priority *int Name string Operator string Value ValueNode Fact string FactResult Fact Result bool Params map[string]interface{} Condition string All []*Condition Any []*Condition Not *Condition }
Condition represents an individual condition within a rule in the rules engine. Conditions can compare facts to values using operators, and they can also nest other conditions. Fields: - Priority: Optional priority of the condition, must be greater than zero if set. - Name: The name of the condition. - Operator: The operator to be applied for comparison (e.g., equals, greaterThan). - Value: The value to compare the fact to. - Fact: The fact that is being evaluated in the condition. - FactResult: The result of fact evaluation. - Result: The evaluation result of the condition (true/false). - Params: Additional parameters that may affect the condition's evaluation. - Condition: Raw condition string (for debugging or custom use cases). - All, Any: Nested conditions that require all or any of the sub-conditions to be true. - Not: A nested condition that negates its result.
func (*Condition) Evaluate ¶
func (c *Condition) Evaluate(almanac *Almanac, operatorMap map[string]Operator) (*EvaluationResult, error)
Evaluate evaluates the condition against the given almanac and operator map
func (*Condition) IsBooleanOperator ¶
IsBooleanOperator returns whether the operator is boolean ('all', 'any', 'not')
func (*Condition) IsConditionReference ¶
isConditionReference returns whether the condition represents a reference to a condition
func (*Condition) ToJSON ¶
ToJSON converts the Condition instance to a JSON string representation. Useful for serializing the condition for storage or transmission.
func (*Condition) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON is a custom JSON unmarshaller for the Condition struct. It validates the condition after unmarshalling to ensure it adheres to the rules. Params: - data: JSON data representing the condition. Returns an error if the condition is invalid after unmarshalling.
func (*Condition) Validate ¶ added in v0.2.0
Validate checks if the Condition is valid based on business rules. It verifies that if a value, fact, or operator are set, all three must be set. It also ensures that if nested conditions (Any, All, Not) are provided, no value, fact, or operator is set. Returns an error if the condition is invalid
type ConditionMap ¶ added in v0.2.0
func (*ConditionMap) Load ¶ added in v0.2.0
func (m *ConditionMap) Load(key string) (Condition, bool)
func (*ConditionMap) Store ¶ added in v0.2.0
func (m *ConditionMap) Store(key string, value Condition)
type ConditionProperties ¶
type ConditionProperties struct { Fact string `json:"fact"` Operator string `json:"operator"` Value interface{} `json:"value"` Path *string `json:"path,omitempty"` Priority *int `json:"priority,omitempty"` Params map[string]interface{} `json:"params,omitempty"` Name *string `json:"name,omitempty"` }
ConditionProperties represents a condition inEvaluator the rule.
func (*ConditionProperties) SetName ¶
func (c *ConditionProperties) SetName(name string)
func (*ConditionProperties) SetPriority ¶
func (c *ConditionProperties) SetPriority(priority int)
type DynamicFactCallback ¶
type Engine ¶
type Engine struct { Rules []*Rule AllowUndefinedFacts bool AllowUndefinedConditions bool ReplaceFactsInEventParams bool Operators map[string]Operator Facts FactMap Conditions ConditionMap Status string // contains filtered or unexported fields }
func NewEngine ¶
func NewEngine(rules []*Rule, options *RuleEngineOptions) *Engine
NewEngine creates a new Engine instance with the provided rules and options. If no options are passed, default options are used. Params: - rules: A slice of rules to be added to the engine. - options: Configuration options for the engine (can be nil). Returns a pointer to the newly created Engine.
func (*Engine) AddCalculatedFact ¶ added in v0.2.0
func (e *Engine) AddCalculatedFact(path string, method DynamicFactCallback, options *FactOptions) error
AddCalculatedFact adds a calculated fact definition to the engine Params: path: The path of the fact. method: The callback function to be executed when the fact is evaluated. options: Additional options for the fact. Returns an error if the fact cannot be added.
func (*Engine) AddFact ¶
func (e *Engine) AddFact(path string, value *ValueNode, options *FactOptions) error
AddFact adds a fact definition to the engine Params: path: The path of the fact. value: The value of the fact. options: Additional options for the fact. Returns an error if the fact cannot be added.
func (*Engine) AddOperator ¶
AddOperator adds a custom operator definition Params: - operatorOrName: The operator to be added, or the name of the operator. - cb: The callback function to be executed when the operator is evaluated.
func (*Engine) AddRule ¶
AddRule adds a single rule to the rules engine. The rule is linked to the engine and stored in the engine's rules list. Params: - rule: The rule to be added to the engine. Returns an error if the rule is invalid or cannot be added.
func (*Engine) AddRuleFromMap ¶ added in v0.2.0
func (e *Engine) AddRuleFromMap(rp *RuleConfig) error
AddRuleFromMap adds a rule to the engine from a configuration map. The rule is created from the map and then added to the engine. Params: - rp: The rule configuration in map form. Returns an error if the rule configuration is invalid.
func (*Engine) AddRules ¶ added in v0.2.0
AddRules adds multiple rules to the engine in a single operation. Each rule is validated and added to the engine. Params: - rules: A slice of rules to be added to the engine. Returns an error if any rule cannot be added.
func (*Engine) EvaluateRules ¶
func (e *Engine) EvaluateRules(rules []*Rule, almanac *Almanac, ctx *ExecutionContext) error
EvaluateRules runs an array of rules Params: - rules: The rules to be evaluated. - almanac: The almanac containing facts and results. - ctx: The execution context for the rules. Returns an error if any rule evaluation fails.
func (*Engine) GetFact ¶
GetFact returns a fact by path Params: path: The path of the fact to be retrieved. Returns the fact if it exists, or nil if it does not.
func (*Engine) GetRules ¶
GetRules returns all rules in the engine. Returns a slice of all rules in the engine.
func (*Engine) PrioritizeRules ¶
PrioritizeRules iterates over the engine rules, organizing them by highest -> lowest priority Returns a 2D slice of rules, where each inner slice contains rules of the same priority
func (*Engine) RemoveCondition ¶
RemoveCondition removes a condition that has previously been added to this engine Params: - name: The name of the condition to be removed. Returns true if the condition was removed, false if it was not found.
func (*Engine) RemoveFact ¶
RemoveFact removes a fact from the engine Params: path: The path of the fact to be removed. Returns true if the fact was removed, false if it was not found.
func (*Engine) RemoveOperator ¶
RemoveOperator removes a custom operator definition Params: - operatorOrName: The operator to be removed, or the name of the operator. Returns true if the operator was removed, false if it was not found.
func (*Engine) RemoveRule ¶
RemoveRule removes an existing rule in the engine. Params: - r: The updated rule. Returns an error if the rule cannot be found or updated.
func (*Engine) RemoveRuleByName ¶ added in v0.2.0
RemoveRuleByName removes an existing rule in the engine by its name. Params: - name: The name of the rule to be removed. Returns true if the rule was removed, false if it was not found.
func (*Engine) RunWithMap ¶ added in v0.2.0
func (*Engine) Stop ¶
Stop stops the rules engine from running the next priority set of Rules Returns the engine instance
func (*Engine) UpdateRule ¶
UpdateRule updates an existing rule in the engine by its name. If the rule exists, it is replaced by the new version. Params: - r: The updated rule. Returns an error if the rule cannot be found or updated.
type EvaluationResult ¶
type EventCallback ¶
type EventCallback func(result *RuleResult) interface{}
type EventConfig ¶ added in v0.2.0
type EventHandler ¶
type EventHandler func(event Event, almanac Almanac, ruleResult RuleResult)
EventHandler represents an event handler function.
type EventOutcome ¶ added in v0.2.0
type EventOutcome string
const ( Success EventOutcome = "success" Failure EventOutcome = "failure" )
type ExecutionContext ¶
type ExecutionContext struct { context.Context Cancel context.CancelFunc StopEarly bool Message string Errors []error }
ExecutionContext holds metadata and control flags for rule execution.
func NewEvaluationContext ¶
func NewEvaluationContext(ctx context.Context) *ExecutionContext
func (*ExecutionContext) AddError ¶
func (c *ExecutionContext) AddError(err error)
type Fact ¶
type Fact struct { Value *ValueNode Path string CalculationMethod DynamicFactCallback Cached bool Priority int Dynamic bool }
Fact represents a fact within the rules engine. It holds a value (as a ValueNode), a path identifying the fact, and optional metadata about how the value was calculated.
func NewCalculatedFact ¶ added in v0.2.0
func NewCalculatedFact(path string, method DynamicFactCallback, options *FactOptions) *Fact
NewCalculatedFact creates a new Fact instance with a dynamic calculation method. Params: path: The path identifying the fact. method: The method to calculate the fact value. options: Optional configuration options for the fact.
func NewFact ¶
func NewFact(path string, value ValueNode, options *FactOptions) (*Fact, error)
NewFact creates a new Fact instance with a static value. Params: path: The path identifying the fact. value: The value of the fact. options: Optional configuration options for the fact.
func (*Fact) Calculate ¶
Calculate evaluates the fact value using the provided Almanac and optional parameters. If the fact is dynamic, it uses the calculation method to determine the value. Params: almanac: The Almanac instance to use for calculation. params: Optional parameters to pass to the calculation method.
type FactMap ¶ added in v0.2.0
type FactMap struct {
// contains filtered or unexported fields
}
FactMap is a thread-safe map used to store and manage facts in the rules engine. It provides methods for setting, loading, and deleting facts, as well as iterating over the map.
func (*FactMap) Delete ¶ added in v0.2.0
Delete removes a fact from the FactMap using the hashed key. Params: - key: The key associated with the fact to be removed.
func (*FactMap) Load ¶ added in v0.2.0
Load retrieves a fact from the FactMap using the hashed key. Params: - key: The key associated with the fact. Returns: - A pointer to the Fact, and a boolean indicating whether the fact was found.
func (*FactMap) LoadOrStore ¶ added in v0.2.0
LoadOrStore retrieves a fact from the FactMap if it exists, or stores the provided fact if it does not. Params: - key: The key to associate with the fact. - value: The fact to store if the key does not exist. Returns: - A pointer to the actual fact (either loaded or newly stored), and a boolean indicating if it was already present.
type FactOptions ¶
type InvalidRuleError ¶ added in v0.2.0
InvalidRuleError represents an error for an invalid rule
func NewInvalidPriorityTypeError ¶ added in v0.2.0
func NewInvalidPriorityTypeError() *InvalidRuleError
func NewInvalidPriorityValueError ¶ added in v0.2.0
func NewInvalidPriorityValueError() *InvalidRuleError
func NewInvalidRuleError ¶ added in v0.2.0
func NewInvalidRuleError(message string, code string) *InvalidRuleError
func NewPriorityNotSetError ¶ added in v0.2.0
func NewPriorityNotSetError() *InvalidRuleError
func (*InvalidRuleError) Error ¶ added in v0.2.0
func (e *InvalidRuleError) Error() string
type Operator ¶
type Operator struct { Name string Callback func(a, b *ValueNode) bool FactValueValidator func(factValue *ValueNode) bool }
Operator defines a function that compares two ValueNodes and returns a boolean result. Operators are used in conditions to perform comparisons like equals, greater than, etc.
func DefaultOperators ¶
func DefaultOperators() []Operator
DefaultOperators returns a slice of default operators
type Options ¶
type Options struct {
AllowUndefinedFacts *bool // Optional flag to allow undefined facts
}
Options defines the optional settings for the Almanac. It includes a flag to allow or disallow the use of undefined facts during rule evaluation.
type Rule ¶
type Rule struct { Priority int Name string Conditions Condition RuleEvent Event Engine *Engine // contains filtered or unexported fields }
Rule represents a rule in the engine. A rule has conditions, actions, and a priority level that determines its order of execution.
func (*Rule) Evaluate ¶
func (r *Rule) Evaluate(ctx *ExecutionContext, almanac *Almanac) (*RuleResult, error)
Evaluate checks if the conditions of the rule are satisfied based on the given facts. Params: - almanac: The almanac containing facts for evaluation. Returns true if the rule's conditions are met, false otherwise.
func (*Rule) GetConditions ¶
GetConditions returns the event object
type RuleConfig ¶ added in v0.2.0
type RuleConfig struct { Name string `json:"name"` Priority *int `json:"priority"` Conditions Condition `json:"conditions"` Event EventConfig `json:"event"` OnSuccess func(result *RuleResult) interface{} OnFailure func(result *RuleResult) interface{} }
func (*RuleConfig) UnmarshalJSON ¶ added in v0.2.0
func (r *RuleConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON is a custom JSON unmarshaller for RuleConfig to ensure proper unmarshaling of Condition
type RuleEngineOptions ¶
type RuleEngineOptions struct { AllowUndefinedFacts bool AllowUndefinedConditions bool ReplaceFactsInEventParams bool }
func DefaultRuleEngineOptions ¶
func DefaultRuleEngineOptions() *RuleEngineOptions
DefaultRuleEngineOptions returns a default set of options for the rules engine. This includes whether undefined facts or conditions are allowed, and if facts should be replaced in event parameters.
type RuleProperties ¶
type RuleProperties struct { Conditions TopLevelCondition `json:"conditions"` Event Event `json:"event"` Name *string `json:"name,omitempty"` Priority *int `json:"priority,omitempty"` OnSuccess *EventHandler `json:"onSuccess,omitempty"` OnFailure *EventHandler `json:"onFailure,omitempty"` }
RuleProperties represents the properties of a rule.
type RuleResult ¶
type RuleResult struct { Conditions Condition Event Event Priority int Name string Result *bool // contains filtered or unexported fields }
RuleResult represents the result of a rule evaluation
func NewRuleResult ¶
func NewRuleResult(conditions Condition, event Event, priority int, name string) *RuleResult
NewRuleResult creates a new RuleResult instance
func (*RuleResult) ResolveEventParams ¶
func (rr *RuleResult) ResolveEventParams(almanac *Almanac) error
ResolveEventParams resolves the event parameters using the given almanac
func (*RuleResult) SetResult ¶
func (rr *RuleResult) SetResult(result *bool)
SetResult sets the result of the rule evaluation
func (*RuleResult) ToJSON ¶
func (rr *RuleResult) ToJSON(stringify bool) (interface{}, error)
ToJSON converts the rule result to a JSON-friendly structure
type TopLevelCondition ¶
type TopLevelCondition struct { All *[]ConditionProperties `json:"all,omitempty"` Any *[]ConditionProperties `json:"any,omitempty"` Not *ConditionProperties `json:"not,omitempty"` Condition *string `json:"condition,omitempty"` Name *string `json:"name,omitempty"` Priority *int `json:"priority,omitempty"` }
TopLevelCondition represents the top-level condition, which can be AllConditions, AnyConditions, NotConditions, or ConditionReference.
type UndefinedFactError ¶
UndefinedFactError represents an error for an undefined fact
func NewUndefinedFactError ¶
func NewUndefinedFactError(message string) *UndefinedFactError
NewUndefinedFactError creates a new UndefinedFactError instance
func (*UndefinedFactError) Error ¶
func (e *UndefinedFactError) Error() string
Error implements the error interface for UndefinedFactError
type ValueNode ¶ added in v0.2.0
type ValueNode struct { Type DataType Bool bool Number float64 String string Array []ValueNode Object map[string]ValueNode }
ValueNode represents a value used in conditions and comparisons. It supports types such as strings, numbers, booleans, arrays, and null.
func NewValueFromGjson ¶ added in v0.2.0
NewValueFromGjson converts a gjson.Result into a ValueNode. It handles various data types such as null, string, number, boolean, and arrays. Params: - result: The gjson.Result to be converted. Returns a pointer to a ValueNode representing the result.