Today we did some interesting observation with des...
# lucee
w
Today we did some interesting observation with deserializeJSON. A string within some deserialized json object is not the same as a string which was directly assigned to the same key in this object. It looks exactly the same, but not a string ??? 🤔
Copy code
<cfscript>
field = deserializeJson('{
			"validation": {
				"id": 1180,
				"regex": "somestring",
				"mask": "",
				"size": "",
				"maxLength": "100"
			}
		}');
writeDump(
    label="initial value",
    var=field.validation.regex
);
writeDump(field.validation.regex === "somestring");
field.validation.regex = "somestring";
writeDump(
    label="assigned empty string value",
    var=field.validation.regex
);
writeDump(field.validation.regex === "somestring");
</cfscript>
so when doing a strict equality they are not the same. See
somestring
here for the example. If we do the same with ACF2021, no problems. Try it yourself https://trycf.com/gist/2cd908188eab1e1a4d8460392a5a3a11/acf2021?theme=monokai
s
could this be the result of how Adobe uses “===” to test if the objects are the same type, and Lucee uses “===” to check if the objects occupy the same memory location?
t
⬆️ === is like java not javascript, it means a is the same object as b not a is the same value as b