The auto_explain module appears to create invalid JSON (in all versions
since 9.0). For example, with the settings
auto_explain.log_format = 'json'
auto_explain.log_min_duration = 0
the query
select * from pg_type;
produces this in the log:
LOG: duration: 529.808 ms plan: [ "Query Text": "select * from pg_type;", "Plan": {
"NodeType": "Seq Scan", "Relation Name": "pg_type", "Alias": "pg_type", "Startup Cost":
0.00, "Total Cost": 9.87, "Plan Rows": 287, "Plan Width": 611 } ]
Note that at the top level, it uses the array delimiters [ ] for what is
actually an object (key/value). Running this through a JSON parser will
fail.
By contrast, EXPLAIN (FORMAT JSON) on the command line produces:
QUERY PLAN
-----------------------------------[ { "Plan": { "Node Type": "Seq Scan", "Relation Name": "pg_type",
"Alias": "pg_type", "Startup Cost": 0.00, "Total Cost": 9.87, "Plan Rows": 287, "Plan Width": 611
} }]
(1 row)
So there is evidently something out of sync between what EXPLAIN and
what auto_explain produces.