Add JSON_UNESCAPED_SLASHES option to json_encode#12987
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pass
JSON_UNESCAPED_SLASHESto PHP's nativejson_encodeinhaxe.Json.stringify.PHP escapes
/as"\/"by default, while other targets (JSJSON.stringify, HaxeJsonPrinter, 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_SLASHEShas 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