James A Mohler
James A Mohler

Reputation: 11120

JSON return null in ColdFusion

I want to return a null as a part of my JSON response

local.JSON = { "pwdstate" : null, "pwdconfirmstate" : null, "content" : "" };
...
framework.renderData().data( SerializeJSON(local.JSON) ).type( "rawjson" );

But I get an error that says Variable NULL is undefined.

How do I send back a null?

Note: Non-existence is not an option

Upvotes: 0

Views: 185

Answers (1)

Alex
Alex

Reputation: 7833

The literal null expression was introduced in ColdFusion 2018. You still need to explicitly enabled it, either on server level (admin panel, Admin API) or on application level (this.enableNullSupport = true in Application.cfc).

You can work around it using javaCast("null", "") for all versions >= ColdFusion 7 and <= ColdFusion 2016.

Upvotes: 2

Related Questions