File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -380,12 +380,18 @@ impl JsonValue {
380380 }
381381
382382 /// Works on `JsonValue::Array` - checks if the array contains a value
383- pub fn contains < T > ( & self , item : T ) -> bool where T : Into < JsonValue > {
383+ pub fn contains < T > ( & self , item : T ) -> bool where T : PartialEq < JsonValue > {
384384 match * self {
385- JsonValue :: Array ( ref vec) => {
386- vec. contains ( & item. into ( ) )
387- } ,
388- _ => false
385+ JsonValue :: Array ( ref vec) => vec. iter ( ) . any ( |member| item == * member) ,
386+ _ => false
387+ }
388+ }
389+
390+ /// Works on `JsonValue::Object` - checks if the object has a key
391+ pub fn has_key ( & self , key : & str ) -> bool {
392+ match * self {
393+ JsonValue :: Object ( ref object) => object. get ( key) . is_some ( ) ,
394+ _ => false
389395 }
390396 }
391397
You can’t perform that action at this time.
0 commit comments