diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ed25715..7aceafa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## Adminer dev +- Pretty print JSON in edit - PostgreSQL: Mark unique partial indexes as unique (bug #1172) - ClickHouse: Fix offset (bug #1188) - ClickHouse: Fix list of tables (bug #1176) diff --git a/adminer/include/html.inc.php b/adminer/include/html.inc.php index 8588b386..0a4b22f7 100644 --- a/adminer/include/html.inc.php +++ b/adminer/include/html.inc.php @@ -254,7 +254,10 @@ function input(array $field, $value, ?string $function, ?bool $autofocus = false } elseif (is_blob($field) && ini_bool("file_uploads")) { echo ""; } elseif ($function == "json" || preg_match('~^jsonb?$~', $field["type"])) { - echo "" . h($value) . ''; + echo "" . h($value == '' || (JUSH == "pgsql" && $field["type"] == "json") + ? $value + : json_encode(json_decode($value), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)) + . ''; } elseif (($text = preg_match('~text|lob|memo~i', $field["type"])) || preg_match("~\n~", $value)) { if ($text && JUSH != "sqlite") { $attrs .= " cols='50' rows='12'";