@@ -112,10 +112,12 @@ private void _parse(string json)
112112 else if ( new [ ] { "_in" , "_nin" } . Contains ( key ) )
113113 {
114114 var array = JsonConvert . DeserializeObject < T [ ] > ( value . ToString ( ) ?? string . Empty ) ;
115- if ( array is null || array . Length == 0 )
115+ // Treat empty arrays as a valid value (resulting in a predicate that's always false for _in
116+ // and always true for _nin). Only null is considered invalid.
117+ if ( array is null )
116118 {
117119 throw new ArgumentException (
118- $ "JSON filter rule is invalid. Array under { key } is null or empty .") ;
120+ $ "JSON filter rule is invalid. Array under { key } is null.") ;
119121 }
120122
121123 deserializedJson [ key ] = array ;
@@ -135,12 +137,19 @@ private void _parse(string json)
135137 ? typeof ( ValueTuple < , > ) . MakeGenericType ( propertyType , propertyType )
136138 : typeof ( Tuple < , > ) . MakeGenericType ( propertyType , propertyType ) ;
137139
138- deserializedJson [ key ] = Activator . CreateInstance ( tupleType ,
140+ var tupleInstance = Activator . CreateInstance ( tupleType ,
139141 OperandToExpressionResolver . ConvertValue ( propertyInfo ? . PropertyType ?? GetFilterType ( ) ,
140142 array [ 0 ] . ToString ( ) ) ,
141143 OperandToExpressionResolver . ConvertValue ( propertyInfo ? . PropertyType ?? GetFilterType ( ) ,
142144 array [ 1 ] . ToString ( ) )
143145 ) ;
146+
147+ if ( tupleInstance == null )
148+ {
149+ throw new InvalidOperationException ( $ "Failed to create tuple instance for key { key } ") ;
150+ }
151+
152+ deserializedJson [ key ] = tupleInstance ;
144153 }
145154 else if ( key . StartsWith ( "_" ) )
146155 {
0 commit comments