I have a array that looks like this:
[
{
"id": 1,
"version": "2.3.4"
},
{
"id": 2,
"version": "1.4.4"
},
{
"id": 3,
"version": "0.0.4"
},
{
"id": 4,
"version": "1.3.4"
},
]
And I need to get all the objects where the version is "1.2.0". I am interested in a built in way using JQ but I cannot find anything related. Maybe it does not exist?
I know I could do some ugly regex hack here, but what would be the right way to solve this so I can easily swap my condition so if instead of 1.2.0 maybe in a short time in the future lets say I want the objects with version greater than 1.2.7 for instance?
You always have the option of parsing and implementing the comparisons.
Then utilize the new comparison functions:
At first I wasn't sure if it was possible to use arrays as the semver key, but it appears it is possible, but requires some additional data points to sort on.
This allows you to sort by the versions.
Assuming this works, this could simplify the
cmp_semver/1function greatly.