01mf02 / jaq

A jq clone focussed on correctness, speed, and simplicity
MIT License
2.7k stars 67 forks source link

Abstract core #187

Closed 01mf02 closed 3 months ago

01mf02 commented 3 months ago

This PR makes a large number of filters from the core library available for general types of values, whereas before, these filters worked only for JSON values. This builds on the ValT trait introduced in jaq 1.4. However, the functions in jaq_interpret::ValT do not suffice for many operations in the core library, which is why it adds a new jaq_core::ValT trait with a few more functions. If you want to use the core library with a non-JSON value type, then you have to implement the new jaq_core::ValT trait for your value type.

This PR should not change the behaviour for JSON values, with one exception: match/1 and match/2 do not create a field name in capturing groups where a name was not given. Before, a field name would be created and set to null. This change is because the core library now never creates null values. The expected impact of this change is small, because .name on a capture group will still return null.