11#
22# Copyright Robert Yokota
3- #
3+ #
44# Licensed under the Apache License, Version 2.0 (the "License")
55# you may not use this file except in compliance with the License.
66# You may obtain a copy of the License at
@@ -67,6 +67,7 @@ def is_array_of_numbers(v: Optional[Any]) -> bool:
6767 @staticmethod
6868 def is_function (o : Optional [Any ]) -> bool :
6969 from jsonata import jsonata
70+
7071 return isinstance (o , jsonata .Jsonata .JFunctionCallable )
7172
7273 NONE = object ()
@@ -90,6 +91,27 @@ def create_sequence_from_iter(it: Iterable) -> list:
9091 sequence .sequence = True
9192 return sequence
9293
94+ @staticmethod
95+ def is_deep_equal (lhs : Optional [Any ], rhs : Optional [Any ]) -> bool :
96+ if isinstance (lhs , list ) and isinstance (rhs , list ):
97+ if len (lhs ) != len (rhs ):
98+ return False
99+ for ii , _ in enumerate (lhs ):
100+ if not Utils .is_deep_equal (lhs [ii ], rhs [ii ]):
101+ return False
102+ return True
103+ elif isinstance (lhs , dict ) and isinstance (rhs , dict ):
104+ if lhs .keys () != rhs .keys ():
105+ return False
106+ for key in lhs .keys ():
107+ if not Utils .is_deep_equal (lhs [key ], rhs [key ]):
108+ return False
109+ return True
110+ if lhs == rhs and type (lhs ) == type (rhs ):
111+ return True
112+
113+ return False
114+
93115 class JList (list ):
94116 sequence : bool
95117 outer_wrapper : bool
@@ -176,3 +198,4 @@ def recurse(val: Optional[Any]) -> None:
176198 def convert_nulls (res : Optional [Any ]) -> Optional [Any ]:
177199 Utils .recurse (res )
178200 return Utils .convert_value (res )
201+ False
0 commit comments