Something like Clojure would be perfect for this. Write a macro that converts
{"name" (includes? "k"), "age" (< 20)}
into {"name" #(includes? % "k"), "age" #(< % 20)}
which is the same as {"name" (fn [name] (includes? name "k")), "age" (fn [age] (< age 20))}
Then have another macro that converts that into the pattern matching code, or maybe there's already something in the standard library.You could serialize the patterns using EDN as a substitute for JSON.
Fun stuff.
I wrote something [similar][1] in javascript. With that it would be:
const is_k_kid = tisch.compileFunction((etc) => ({
'name': name => name.includes('k'),
'age': age => age < 20,
...etc
}));
const result = input.filter(is_k_kid);
Yes, "...etc" is part of the DSL.