I think you can get the output as JSON using FORMATTED. You can try:
FORMATTED
EXPLAIN FORMATTED query
This should give you the explain output in JSON format.