Skip to content

Commit

Permalink
Comparing two JSON objects
Browse files Browse the repository at this point in the history
Comparing two JSON objects works.
Fixes issue #890
  • Loading branch information
kortenkamp committed Sep 6, 2022
2 parents 3c94285 + 2ad54df commit bf6f518
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/js/libcs/Essentials.js
Expand Up @@ -232,6 +232,7 @@ eval_helper.evaluate = function (name, args, modifs) {
};

eval_helper.equals = function (v0, v1) {
// TODO: use this everywhere where elements are compared (see function comp_equals(args, modifs) )
//Und nochmals un-OO
if (v0.ctype === "number" && v1.ctype === "number") {
return {
Expand Down Expand Up @@ -261,6 +262,12 @@ eval_helper.equals = function (v0, v1) {
value: v0.value === v1.value,
};
}
if (v0.ctype === "JSON" && v1.ctype === "JSON") {
return {
ctype: "boolean",
value: v0.value === v1.value,
};
}
return {
ctype: "boolean",
value: false,
Expand Down
3 changes: 3 additions & 0 deletions src/js/libcs/Operators.js
Expand Up @@ -874,6 +874,9 @@ function comp_equals(args, modifs) {
if (v0.ctype === "geo") {
return General.bool(v0.value === v1.value);
}
if (v0.ctype === "JSON") {
return General.bool(v0.value === v1.value);
}
}
return {
ctype: "boolean",
Expand Down
14 changes: 14 additions & 0 deletions tests/JSON_tests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf6f518

Please sign in to comment.