From f82ebb42b86e951f0c370785c6b42789b820e34e Mon Sep 17 00:00:00 2001 From: Diego Henrique Oliveira Date: Wed, 3 Apr 2024 20:20:30 -0300 Subject: [PATCH] Deprecate ApplyInterface --- jsonlogic.go | 6 ++++++ readme.md | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jsonlogic.go b/jsonlogic.go index fc7cdd4..c212312 100644 --- a/jsonlogic.go +++ b/jsonlogic.go @@ -550,6 +550,8 @@ func GetJsonLogicWithSolvedVars(rule, data json.RawMessage) ([]byte, error) { return solveVarsBackToJsonLogic(_rule, _data) } +// ApplyRaw receives a rule and data as json.RawMessage and returns the result +// of the rule applied to the data. func ApplyRaw(rule, data json.RawMessage) (json.RawMessage, error) { if data == nil { data = json.RawMessage("{}") @@ -576,6 +578,10 @@ func ApplyRaw(rule, data json.RawMessage) (json.RawMessage, error) { return json.Marshal(&result) } +// ApplyInterface receives a rule and data as interface{} and returns the result +// of the rule applied to the data. +// +// Deprecated: Use Apply instead because ApplyInterface will be private in the next version. func ApplyInterface(rule, data interface{}) (output interface{}, err error) { defer func() { if e := recover(); e != nil { diff --git a/readme.md b/readme.md index 053340a..4064715 100644 --- a/readme.md +++ b/readme.md @@ -138,7 +138,7 @@ func main() { } ``` -If you want to get the JsonLogic used, with the variables replaced by their values: +If you want to get the JsonLogic used, with the variables replaced by their values: ```go package main @@ -159,7 +159,7 @@ func main() { if err != nil { fmt.Println(err) } - + fmt.Println(string(result)) // will output { "==":[false, true] } } ```