For analyzing/filtering a custom JSON stream there are not much tools available. Hence this library provides some simple API for filtering out json packet.
Json object is passed through one or more rule(s), if it matches any of the rules then its a pass condition.
# Anything starting with # are comments
# Parent node being an array
if json[0].method == "object.updated" {
if json[0].params.object.id == 205793453 {
pp
}
# Iterate through the list
for rule in json[0].params.object.rules {
if rule.ruleName == "Match" {
if rule.active == true {
pp
}
}
}
}
# Parent node being an object
if json.method == "object.update" {
pp
}
# Many such rules can be written
As you can see above, you can write your own custom rules, if a match condition (pp) is encountered then it just returns success.
Please note :- Once a match condition is encountered it doesn't execute subsequent statements.
Check these sample rules for more complex rules.
- json -> Denotes parent node
- if -> Comparing conditions
- for -> Loops through a list
- in -> Used along with for
- pp -> pass condition
- Supports recurssive if and for loop.
- Supports comparison in the form of string.
- Supports implementation in c++.
- Supports comparison of basic data types like string, int64, bool, double.
- Supports more comparison operators like >, >=, <, <=, ==.
- Supports implementation in go.
- PYTHON support.
- Support for boolean operators (and/or).
- Beggining of the line must not be empty.
- Validation of the statements are not done.
- Go implementation has issues while comparing int64 numbers