Pretty print JSON in edit

This commit is contained in:
Jakub Vrana
2025-12-02 10:39:23 +01:00
parent 53d7e31bf6
commit a49fcf4799
2 changed files with 5 additions and 1 deletions

View File

@@ -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)

View File

@@ -254,7 +254,10 @@ function input(array $field, $value, ?string $function, ?bool $autofocus = false
} elseif (is_blob($field) && ini_bool("file_uploads")) {
echo "<input type='file' name='fields-$name'>";
} elseif ($function == "json" || preg_match('~^jsonb?$~', $field["type"])) {
echo "<textarea$attrs cols='50' rows='12' class='jush-js'>" . h($value) . '</textarea>';
echo "<textarea$attrs cols='50' rows='12' class='jush-js'>" . h($value == '' || (JUSH == "pgsql" && $field["type"] == "json")
? $value
: json_encode(json_decode($value), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE))
. '</textarea>';
} elseif (($text = preg_match('~text|lob|memo~i', $field["type"])) || preg_match("~\n~", $value)) {
if ($text && JUSH != "sqlite") {
$attrs .= " cols='50' rows='12'";