Skip to content

[6.x] Let to_json output null for null values - #15847

Closed
mynetx wants to merge 2 commits into
statamic:6.xfrom
mynetx:fix/to-json-null
Closed

mynetx wants to merge 2 commits into
statamic:6.xfrom
mynetx:fix/to-json-null

Conversation

@mynetx

@mynetx mynetx commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #15832

Since #15540, a Value wrapping null stops the modifier chain before the modifier runs, so {{ empty_field | to_json }} renders nothing instead of null. Inside a JSON template that leaves invalid JSON like { "items": }.

This adds to_json and its json alias to the null-aware modifiers list from #15782, next to bool_string.

One thing to note: the list applies to bare and missing variables too, so {{ missing | to_json }} now outputs null as well. It output nothing even before #15540, but null seems like the right answer for a JSON modifier, and it matches what #15782 did for bool_string.

🤖 Generated with Claude Code

mynetx and others added 2 commits November 11, 2026 08:44
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasonvarga

Copy link
Copy Markdown
Member

Thanks! Technically correct but I'm going to close this in favor of #15849.

@jasonvarga jasonvarga closed this Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

to_json no longer serializes augmented null values

2 participants