Bug #81276 Support for newlines in json output of mysqlsh
Submitted: 2 May 2016 12:47 Modified: 31 May 2016 13:16
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Document Store: MySQL Shell Severity:S3 (Non-critical)
Version:1.0.3 OS:Any
Assigned to: Juan Rene Ramirez Monarrez CPU Architecture:Any

[2 May 2016 12:47] Daniël van Eeden
Description:
Please replace \n in the json data with actual newlines for readability.

How to repeat:
mysql-sql> show create table testcol;
{
    "executionTime": "0.00 sec",
    "warningCount": 0,
    "warnings": [],
    "rows": [
        {
            "Table": "testcol",
            "Create Table": "CREATE TABLE `testcol` (\n  `doc` json DEFAULT NULL,\n  `_id` varchar(32) GENERATED ALWAYS AS (json_unquote(json_extract(`doc`,'$._id'))) STORED NOT NULL,\n  UNIQUE KEY `_id` (`_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
        }
    ],
    "hasData": true,
    "affectedRowCount": 0,
    "lastInsertId": -1
}

Suggested fix:
Maybe create an option to turn this on/off.
[2 May 2016 13:42] Umesh Shastry
Hello Daniël,

Thank you for the report.
Verified as described.

Thanks,
Umesh
[31 May 2016 13:16] Erlend Dahl
Posted by developer:

I don't think this is a bug  when JSON output is turned ON, whatever the result of the statement execution is JSON formatted. The new lines you mention come as part of the resulting text and so they are JSON formatted as well.
 
Doing what you request implies tweaking a result (which we don't) and may end
up in invalid JSON data.
 
For readability, the best option is to use other output format, JSON is not
the best option on this case.
 
Anyway, thanks for reviewing the shell!