diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-09 06:25:55 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-09 06:25:55 +1100 |
commit | 35dc974a8f87057c998f44687586a16147dba654 (patch) | |
tree | 7b8ce0977981bcba32c1c4088f0d26389a3cb99c /source/core/StarJson.cpp | |
parent | 1cf7baa317e341a3fbca77454aa21a13440470ed (diff) | |
parent | 15a12c06a66adca4c953be8af6fc434cb6d2b156 (diff) |
Merge pull request #28 from JamesTheMaker/main
Added many new patch features
Diffstat (limited to 'source/core/StarJson.cpp')
-rw-r--r-- | source/core/StarJson.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/core/StarJson.cpp b/source/core/StarJson.cpp index 3feaf37..ed0e48f 100644 --- a/source/core/StarJson.cpp +++ b/source/core/StarJson.cpp @@ -1035,4 +1035,34 @@ Json jsonMerge(Json const& base, Json const& merger) { } } +bool jsonCompare(Json const& base, Json const& compare) { + if (base == compare) { + return true; + } else { + if (base.type() == Json::Type::Object && compare.type() == Json::Type::Object) { + for (auto const& c : compare.toObject()) { + if (!base.contains(c.first) || !jsonCompare(base.get(c.first), c.second)) + return false; + } + return true; + } + if (base.type() == Json::Type::Array && compare.type() == Json::Type::Array) { + for (auto const& c : compare.toArray()) { + bool similar = false; + for (auto const& b : base.toArray()) { + if (jsonCompare(c, b)) { + similar = true; + break; + } + } + if (!similar) + return false; + } + return true; + } + + return false; + } +} + }
\ No newline at end of file |