Related Documentation Download this Manual
PDF (US Ltr) - 367.2Kb
PDF (A4) - 365.0Kb
HTML Download (TGZ) - 73.5Kb
HTML Download (Zip) - 85.4Kb


MySQL Shell 8.0  /  ...  /  JSON Format Output

4.6.4 JSON Format Output

The JSON format options print result sets as either raw JSON (json/raw) or pretty-printed JSON (json). To get this output format, start MySQL Shell with the --result-format=json command line option (for pretty-printed JSON) or the --result-format=json/raw command line option, or set the MySQL Shell configuration option resultFormat to json (for pretty-printed JSON) or json/raw.

In batch mode, to help integrate MySQL Shell with external tools, you can use the --json option to control JSON wrapping for all output when you start MySQL Shell from the command line. When JSON wrapping is turned on, MySQL Shell generates either pretty-printed JSON (the default) or raw JSON, and the value of the resultFormat MySQL Shell configuration option is ignored. For instructions, see Section 4.6.5, “JSON Wrapping”.

JSON Format in Interactive Mode (Pretty-Printed JSON)

mysql-sql> select * from sakila.actor limit 3;
{
    "duration": "0.00 sec",
    "info": "",
    "row_count": 3,
    "rows": [
        [
            1,
            "PENELOPE",
            "GUINESS",
            {
                "year": 2006,
                "month": 1,
                "day": 15,
                "hour": 4,
                "minute": 34,
                "second": 33.0
            }
        ],
        [
            2,
            "NICK",
            "WAHLBERG",
            {
                "year": 2006,
                "month": 1,
                "day": 15,
                "hour": 4,
                "minute": 34,
                "second": 33.0
            }
        ],
        [
            3,
            "ED",
            "CHASE",
            {
                "year": 2006,
                "month": 1,
                "day": 15,
                "hour": 4,
                "minute": 34,
                "second": 33.0
            }
        ]
    ],
    "warning_count": 0
}

JSON Format in Interactive Mode (Raw JSON)

mysql-sql> select * from sakila.actor limit 3;
{"duration":"0.00 sec","info":"","row_count":3,"rows":[[1,"PENELOPE","GUINESS",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}],[2,"NICK","WAHLBERG",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}],[3,"ED","CHASE",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}]],"warning_count":0}