Allow to export JSON with unescaped unicode chars
This is optional as there are some parsers which have problems with utf-8, see http://stackoverflow.com/q/4901133/225718 Fixes #12946 Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
8c102dc875
commit
c0bb9520e9
@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog
|
||||
======================
|
||||
|
||||
4.8.0 (not yet released)
|
||||
- issue #12946 Allow to export JSON with unescaped unicode chars
|
||||
|
||||
4.7.0.0 (not yet released)
|
||||
- patch #12233 [Display] Improve message when renaming database to same name
|
||||
|
||||
@ -95,6 +95,7 @@ $post_params = array(
|
||||
'ods_columns',
|
||||
'json_structure_or_data',
|
||||
'json_pretty_print',
|
||||
'json_unicode',
|
||||
'xml_structure_or_data',
|
||||
'xml_export_events',
|
||||
'xml_export_functions',
|
||||
|
||||
@ -1855,6 +1855,13 @@ $cfg['Export']['json_structure_or_data'] = 'data';
|
||||
*/
|
||||
$cfg['Export']['json_pretty_print'] = false;
|
||||
|
||||
/**
|
||||
* Export functions
|
||||
*
|
||||
* @global string $cfg['Export']['json_unicode']
|
||||
*/
|
||||
$cfg['Export']['json_unicode'] = true;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
||||
@ -43,13 +43,18 @@ class ExportJson extends ExportPlugin
|
||||
*/
|
||||
public function encode($data)
|
||||
{
|
||||
$options = 0;
|
||||
if (isset($GLOBALS['json_pretty_print'])
|
||||
&& $GLOBALS['json_pretty_print']
|
||||
) {
|
||||
return json_encode($data, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($data);
|
||||
$options |= JSON_PRETTY_PRINT;
|
||||
}
|
||||
if (isset($GLOBALS['json_unicode'])
|
||||
&& $GLOBALS['json_unicode']
|
||||
) {
|
||||
$options |= JSON_UNESCAPED_UNICODE;
|
||||
}
|
||||
return json_encode($data, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,6 +89,12 @@ class ExportJson extends ExportPlugin
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
|
||||
$leaf = new BoolPropertyItem(
|
||||
'unicode',
|
||||
__('Output unicode characters unescaped')
|
||||
);
|
||||
$generalOptions->addProperty($leaf);
|
||||
|
||||
// add the main group to the root group
|
||||
$exportSpecificOptions->addProperty($generalOptions);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user