Skip to content

Commit

Permalink
Deprecate ApplyInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoholiveira committed Apr 3, 2024
1 parent ea950da commit f82ebb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions jsonlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("{}")
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -159,7 +159,7 @@ func main() {
if err != nil {
fmt.Println(err)
}

fmt.Println(string(result)) // will output { "==":[false, true] }
}
```
Expand Down

0 comments on commit f82ebb4

Please sign in to comment.