File tree 4 files changed +22
-11
lines changed
4 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,10 @@ $rendererOptions = [
108
108
// internally, ops (tags) are all int type but this is not good for human reading.
109
109
// set this to "true" to convert them into string form before outputting.
110
110
'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,
111
115
// change this value to a string as the returned diff if the two input strings are identical
112
116
'resultForIdenticals' => null,
113
117
// extra HTML classes added to the DOM of the diff container
Original file line number Diff line number Diff line change 76
76
// internally, ops (tags) are all int type but this is not good for human reading.
77
77
// set this to "true" to convert them into string form before outputting.
78
78
'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 ,
79
83
// change this value to a string as the returned diff if the two input strings are identical
80
84
'resultForIdenticals ' => null ,
81
85
// extra HTML classes added to the DOM of the diff container
237
241
$ newFile ,
238
242
'Json ' ,
239
243
$ 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
246
252
);
247
253
248
- echo $ beautified ;
254
+ echo $ jsonResult ;
249
255
250
256
?> </code></pre>
251
257
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ abstract class AbstractRenderer implements RendererInterface
67
67
// internally, ops (tags) are all int type but this is not good for human reading.
68
68
// set this to "true" to convert them into string form before outputting.
69
69
'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 ,
70
74
// change this value to a string as the returned diff if the two input strings are identical
71
75
'resultForIdenticals ' => null ,
72
76
// 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
41
41
$ this ->convertTagToString ($ changes );
42
42
}
43
43
44
- return \json_encode (
45
- $ changes ,
46
- \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES
47
- );
44
+ return \json_encode ($ changes , $ this ->options ['jsonEncodeFlags ' ]);
48
45
}
49
46
50
47
/**
You can’t perform that action at this time.
0 commit comments