Skip to content

Add JSON_UNESCAPED_SLASHES option to json_encode#12987

Merged
Simn merged 1 commit into
HaxeFoundation:developmentfrom
kevinresol:patch-14
Jul 10, 2026
Merged

Add JSON_UNESCAPED_SLASHES option to json_encode#12987
Simn merged 1 commit into
HaxeFoundation:developmentfrom
kevinresol:patch-14

Conversation

@kevinresol

@kevinresol kevinresol commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Pass JSON_UNESCAPED_SLASHES to PHP's native json_encode in haxe.Json.stringify.

PHP escapes / as "\/" by default, while other targets (JS JSON.stringify, Haxe JsonPrinter, etc.) leave / unescaped. Both forms are valid JSON and parse identically, but the encoded strings differ across targets (which necessarily increases difficulty if cross-platform libraries want to test the encoded string).

JSON_UNESCAPED_SLASHES has been available since PHP 5.4 (2012), which is what Haxe required since 3.4.0. Enabling it by default aligns PHP output with other targets without changing decoded values.

See #724

Pass JSON_UNESCAPED_SLASHES to PHP's native json_encode in haxe.Json.stringify.

PHP escapes / as \/ by default, while other targets (JS JSON.stringify, Haxe JsonPrinter, etc.) leave / unescaped. Both forms are valid JSON and parse identically, but the encoded strings differ across targets.

JSON_UNESCAPED_SLASHES has been available since PHP 5.4 (2012), which is at or below the minimum PHP version Haxe has required since 3.4.0. Enabling it by default aligns PHP output with other targets without changing decoded values.
@Simn Simn merged commit 5f83789 into HaxeFoundation:development Jul 10, 2026
98 of 100 checks passed
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.

2 participants