File tree Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,10 @@ $rendererOptions = [
108108 // internally, ops (tags) are all int type but this is not good for human reading.
109109 // set this to "true" to convert them into string form before outputting.
110110 'outputTagAsString' => false,
111+ // this option is currently only for the Json renderer.
112+ // it controls how the output JSON is formatted.
113+ // see availabe options on https://www.php.net/manual/en/function.json-encode.php
114+ 'jsonEncodeFlags' => \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE,
111115 // change this value to a string as the returned diff if the two input strings are identical
112116 'resultForIdenticals' => null,
113117 // extra HTML classes added to the DOM of the diff container
Original file line number Diff line number Diff line change 7676 // internally, ops (tags) are all int type but this is not good for human reading.
7777 // set this to "true" to convert them into string form before outputting.
7878 'outputTagAsString ' => false ,
79+ // this option is currently only for the Json renderer.
80+ // it controls how the output JSON is formatted.
81+ // see availabe options on https://www.php.net/manual/en/function.json-encode.php
82+ 'jsonEncodeFlags ' => \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE ,
7983 // change this value to a string as the returned diff if the two input strings are identical
8084 'resultForIdenticals ' => null ,
8185 // extra HTML classes added to the DOM of the diff container
237241 $ newFile ,
238242 'Json ' ,
239243 $ diffOptions ,
240- ['outputTagAsString ' => true ] + $ rendererOptions
241- );
242-
243- $ beautified = \json_encode (
244- \json_decode ($ jsonResult , true ),
245- \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | \JSON_PRETTY_PRINT
244+ [
245+ 'outputTagAsString ' => true ,
246+ 'jsonEncodeFlags ' => (
247+ \JSON_PRETTY_PRINT |
248+ \JSON_UNESCAPED_SLASHES |
249+ \JSON_UNESCAPED_UNICODE
250+ ),
251+ ] + $ rendererOptions
246252 );
247253
248- echo $ beautified ;
254+ echo $ jsonResult ;
249255
250256 ?> </code></pre>
251257
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ abstract class AbstractRenderer implements RendererInterface
6767 // internally, ops (tags) are all int type but this is not good for human reading.
6868 // set this to "true" to convert them into string form before outputting.
6969 'outputTagAsString ' => false ,
70+ // this option is currently only for the Json renderer.
71+ // it controls how the output JSON is formatted.
72+ // see availabe options on https://www.php.net/manual/en/function.json-encode.php
73+ 'jsonEncodeFlags ' => \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE ,
7074 // change this value to a string as the returned diff if the two input strings are identical
7175 'resultForIdenticals ' => null ,
7276 // extra HTML classes added to the DOM of the diff container
Original file line number Diff line number Diff line change @@ -41,10 +41,7 @@ protected function redererChanges(array $changes): string
4141 $ this ->convertTagToString ($ changes );
4242 }
4343
44- return \json_encode (
45- $ changes ,
46- \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES
47- );
44+ return \json_encode ($ changes , $ this ->options ['jsonEncodeFlags ' ]);
4845 }
4946
5047 /**
You can’t perform that action at this time.
0 commit comments