Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarJson.hpp
diff options
context:
space:
mode:
authorJamesTheMaker <jamesthemaker2005@gmail.com>2024-03-07 09:43:36 -0500
committerJamesTheMaker <jamesthemaker2005@gmail.com>2024-03-07 09:43:36 -0500
commit14ec64ace75c83238ee9f81fe4ea4c3c9eed09fb (patch)
tree0cbaa87de247dc914be8a7d5dc7e0540d976c16b /source/core/StarJson.hpp
parentf1e3f6791d18f82e662a54ea407b5e5495e18a30 (diff)
Added `jsonCompare` function
Diffstat (limited to 'source/core/StarJson.hpp')
-rw-r--r--source/core/StarJson.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/core/StarJson.hpp b/source/core/StarJson.hpp
index 4aa6f7b..51e0be7 100644
--- a/source/core/StarJson.hpp
+++ b/source/core/StarJson.hpp
@@ -355,6 +355,22 @@ Json jsonMergeQueryDef(String const& key, Json def, Json const& first, T const&.
return def;
}
+// Compares the two given json values and returns a boolean, by the following
+// rules (applied in order): If both values are identical, return true. If both
+// values are not equal, check if they are objects. If they are objects,
+// iterate through every pair in the comparing object and check if the key is
+// in the base object. If the key is in the base object, then jsonCompare is
+// called recursively on both values. If the base object does not contain the
+// key, or the recursion fails, return false. Otherwise, return true. If they
+// are not objects, check if they are arrays. If they are arrays, iterate
+// through every value in the comparing object and then recursively call
+// jsonCompare on every value in the base object until a match is found. If a
+// match is found, break and move on to the next value in the comparing array.
+// If a match is found for every value in the comparing array, return true.
+// Otherwise, return false. If both values are not identical, and are not
+// objects or arrays, return false.
+bool jsonCompare(Json const& base, Json const& compare);
+
}
template <> struct fmt::formatter<Star::Json> : ostream_formatter {};