When comparing the output of json.getString() to a string of same value i manually inputted into a json file, it's a false comparison.
println("-");
println(jsonScene.getString("value"));
println(jsonScene.getString("value") == "-");
Outputs
-
-
false
The same value is printed but when compared, it's false but should be true.
CodePudding user response:
Remember in Processing (Java) you need to compare Strings using equals()
:
Compares two strings to see if they are the same. This method is necessary because it's not possible to compare strings using the equality operator (==). Returns true if the strings are the same and false if they are not.
For example:
println(jsonScene.getString("value").equals("-"));
CodePudding user response:
- Check the
.charCodeAt(0)
for both strings .trim()
both of them before the comparison- Check that
typeof jsonScene.getString("value") === "string"
(it could be an object with customtoString()
defined)