public class JmesPathTest {
private readonly JObject _objWithDouble = JObject.Parse( """{"fees": [{"fee": 20.0}]}""" );
private readonly JmesPath _jmesPath = new();
// No match
[Fact]
public async Task FilterByIntegerLiteral_MatchesFloatDataValue() {
JToken result = await _jmesPath.TransformAsync( _objWithDouble, "fees[?fee==`20`]" );
Assert.IsType<JArray>( result );
Assert.Single( (JArray) result );
}
// Match
[Fact]
public async Task FilterByFloatLiteral_MatchesFloatDataValue() {
JToken result = await _jmesPath.TransformAsync( _objWithDouble, "fees[?fee==`20.0`]" );
Assert.IsType<JArray>( result );
Assert.Single( (JArray) result );
}
}
Equality filter only matches when type matches (int == int and dbl == dbl, but int != dbl). The above code displays an example of when the filter works as expected and when it does not. The same applies for the reverse (int in array and double in filter). This is not the case for official JMESPath:
The other comparison operators do work (>=, >, etc.)
Equality filter only matches when type matches (
int == intanddbl == dbl, butint != dbl). The above code displays an example of when the filter works as expected and when it does not. The same applies for the reverse (int in array and double in filter). This is not the case for official JMESPath:The other comparison operators do work (>=, >, etc.)