update.
[chise/est.git] / char-db-json.el
index c38d39a..2da62e5 100644 (file)
@@ -30,7 +30,8 @@
 
 (setq char-db-ignored-attributes
       '(ideographic-products
-       ->HNG
+       composition
+        ;; ->HNG
        *instance@ruimoku/bibliography/title
        *instance@morpheme-entry/zh-classical))
 
                     =shinjigen/+p@rev ==shinjigen/+p@rev
                     ===daikanwa/ho ==daikanwa/ho
                     =daikanwa/ho =>>daikanwa/ho =>daikanwa/ho))
-       " %-18s  %4d,\t\"_comment\": \"%c")
+       " %-20s  %4d,\t\"_comment\": \"%c")
        ((eq name '=shinjigen@1ed/24pr)
-       " %-18s  %4d,\t\"_comment\": \"%c")
+       " %-20s  %4d,\t\"_comment\": \"%c")
        ((or
         (memq name
               '(===daikanwa
                 ===hng-smk))
         ;; (string-match "^=adobe-" (symbol-name name))
         )
-       " %-18s %5d,\t\"_comment\": \"%c")
+       " %-20s %5d,\t\"_comment\": \"%c")
        ((memq name '(=hanyo-denshi/ks
                     ==hanyo-denshi/ks ===hanyo-denshi/ks
                     =>>hanyo-denshi/ks
                     =koseki ==koseki
                     =mj ==mj ===mj =>>mj =>mj
                     =zihai mojikyo))
-       " %-18s %6d,\t\"_comment\": \"%c")
+       " %-19s %6d,\t\"_comment\": \"%c")
        ((memq name '(=hanyo-denshi/tk ==hanyo-denshi/tk))
-       " %-18s %8d,\t\"_comment\": \"%c")
+       " %-20s %8d,\t\"_comment\": \"%c")
        ((>= (charset-dimension name) 2)
-       " %-18s %5d,\t\"_comment\": \"%c")
+       " %-20s %5d,\t\"_comment\": \"%c")
        (t
-       " %-18s %3d,\t\"_comment\": \"%c"))
+       " %-20s   %3d,\t\"_comment\": \"%c"))
       (format "\"%s\":" name)
       (if (= (charset-iso-graphic-plane name) 1)
          (logior value
       (insert "\""))
     )
    (t
-    (insert (format " %-18s %s"
+    (insert (format " %-20s %s"
                    (format "\"%s\":" name) value))
     ))
   )
 
 (defun char-db-json-insert-relation-feature (char name value line-breaking
                                             ccss readable)
-  (insert (format " %-18s [%s    "
+  (insert (format " %-20s [%s    "
                  (format "\"%s\":" name) line-breaking))
   (let ((lbs (concat "\n" (make-string (current-column) ?\ )))
        separator cell sources required-features
        ret)
+    (if (characterp value)
+       (setq value (list value)))
     (while (consp value)
       (setq cell (car value))
       (if (integerp cell)
        (if separator
            (insert separator)
          (setq separator (format ",%s" lbs)))
-       (if readable
-           (insert (format "%S" cell))
-         (char-db-json-insert-char-spec cell readable
-                                        nil
-                                        required-features))
+        ;; (if readable
+        ;;     (insert (format "%S" cell))
+        ;;   (char-db-json-insert-char-spec cell readable
+        ;;                                  nil
+        ;;                                  required-features))
+       (char-db-json-insert-char-spec cell readable
+                                      nil
+                                      required-features)
        )
        ((consp cell)
        (if separator
                                          for-sub-node)
   (unless column
     (setq column (current-column)))
-  (let (name value ; has-long-ccs-name
+  (let ((est-view-url-prefix "http://chise.org/est/view")
+       id obj-id type
+       name value ; has-long-ccs-name
        rest
        radical strokes
        (line-breaking
         (concat "\n" (make-string (1+ column) ?\ )))
-       (line-separator nil)
+       line-separator
        lbs cell separator ret
        key al cal
        dest-ccss ; sources required-features
                        (push name atr-d)))
                    atr-d)
                  #'char-attribute-name<)))
-    (insert "{")
+    (insert
+     (format "{ \"@context\": \"%s/genre/character/context.json\""
+            est-view-url-prefix))
+    (setq line-separator (format ",%s" line-breaking))
+    (setq id (www-uri-make-object-url char))
+    (insert (format "%s \"@id\": \"%s\"" line-separator id))
+    (setq obj-id (file-name-nondirectory id))
+    (setq type
+         (cond
+          ((string-match "^a2\\." obj-id)
+           "chise:super-abstract-character")
+          ((string-match "^a\\." obj-id)
+           "chise:abstract-character")
+          ((string-match "^o\\." obj-id)
+           "chise:unified-glyph")
+          ((string-match "^rep\\." obj-id)
+           "chise:abstract-glyph")
+          ((string-match "^g\\." obj-id)
+           "chise:detailed-glyph")
+          ((string-match "^g2\\." obj-id)
+           "chise:abstract-glyph-form")
+          ((string-match "^gi\\." obj-id)
+           "chise:abstract-glyph-form")
+          ((string-match "^repi\\." obj-id)
+           "chise:glyph-image")
+          (t
+           "chise:character")
+          ))
+    (insert (format "%s \"@type\": \"%s\"" line-separator type))
     (when (memq '<-subsumptive attributes)
       (when (or readable (not for-sub-node))
        (when (setq value (get-char-attribute char '<-subsumptive))
+         (insert line-separator)
          (char-db-json-insert-relation-feature char '<-subsumptive value
                                                line-breaking
                                                ccss readable)
-         (setq line-separator (format ",%s" line-breaking))
          ))
       (setq attributes (delq '<-subsumptive attributes))
       )
     (when (and (memq '<-denotational attributes)
               (setq value (get-char-attribute char '<-denotational)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (char-db-json-insert-relation-feature char '<-denotational value
                                            line-breaking
                                            ccss readable)
     (when (and (memq '<-denotational@component attributes)
               (setq value
                     (get-char-attribute char '<-denotational@component)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (char-db-json-insert-relation-feature
        char '<-denotational@component value
        line-breaking
       (setq attributes (delq '<-denotational@component attributes)))
     (when (and (memq 'name attributes)
               (setq value (get-char-attribute char 'name)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format
               (if (> (+ (current-column) (length value)) 48)
-                  "\"name\": %S"
-                "\"name\":               %S")
+                  " \"name\": %S"
+                " \"name\":                 %S")
               value))
       (setq attributes (delq 'name attributes))
       )
     (when (and (memq 'name* attributes)
               (setq value (get-char-attribute char 'name*)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format
               (if (> (+ (current-column) (length value)) 48)
-                  "\"name*\": %S"
-                "{\"name*\":               %S")
+                  " \"name*\": %S"
+                " \"name*\":                 %S")
               value))
       (setq attributes (delq 'name* attributes))
       )
     (when (and (memq 'script attributes)
               (setq value (get-char-attribute char 'script)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
-      (insert (format "{\"script\":\t\t%s}%s"
+      (insert line-separator)
+      (insert (format " \"script\":\t\t  %s"
                      (mapconcat (function prin1-to-string)
-                                value " ")
-                     line-breaking))
+                                value " ")))
       (setq attributes (delq 'script attributes))
       )
     (dolist (name '(=>ucs =>ucs*))
       (when (and (memq name attributes)
                 (setq value (get-char-attribute char name)))
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
-       (insert (format "{\"%-18s\":  #x%04X},\t\"_comment\": \"%c\"%s"
-                       name value (decode-char '=ucs value)
-                       line-breaking))
+       (insert line-separator)
+       (insert (format " \"%-20s\":  #x%04X,\t\"_comment\": \"%c\""
+                       name value (decode-char '=ucs value)))
        (setq attributes (delq name attributes))))
     (dolist (name '(=>ucs@gb =>ucs@big5))
       (when (and (memq name attributes)
                 (setq value (get-char-attribute char name)))
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
-       (insert (format "{\"%-18s\":  #x%04X},\t\"_comment\": \"%c\"%s"
+       (insert line-separator)
+       (insert (format " \"%-20s\":  #x%04X,\t\"_comment\": \"%c\"%s"
                        name value
                        (decode-char (intern
                                      (concat "="
        ))
     (when (and (memq 'general-category attributes)
               (setq value (get-char-attribute char 'general-category)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format
-              "{\"general-category\":\t%s} // %s%s"
+              " \"general-category\":\t [ %s ], \"_comment\": \"%s\""
               (mapconcat (lambda (cell)
                            (format "%S" cell))
                          value " ")
                      "Informative Category")
                     (t
                      "Unknown Category"))
-              line-breaking))
+              ))
       (setq attributes (delq 'general-category attributes))
       )
     (when (and (memq 'bidi-category attributes)
               (setq value (get-char-attribute char 'bidi-category)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
-      (insert (format "{\"bidi-category\":\t %S}%s"
-                     value
-                     line-breaking))
+      (insert line-separator)
+      (insert (format " \"bidi-category\":\t  %S"
+                     value))
       (setq attributes (delq 'bidi-category attributes))
       )
     (unless (or (not (memq 'mirrored attributes))
                (eq (setq value (get-char-attribute char 'mirrored 'empty))
                    'empty))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
-      (insert (format "{\"mirrored\":\t\t %S}%s"
-                     value
-                     line-breaking))
+      (insert line-separator)
+      (insert (format " \"mirrored\":\t\t  %S"
+                     value))
       (setq attributes (delq 'mirrored attributes))
       )
     (cond
      ((and (memq 'decimal-digit-value attributes)
           (setq value (get-char-attribute char 'decimal-digit-value)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
-      (insert (format "{\"decimal-digit-value\":  %S}%s"
-                     value
-                     line-breaking))
+      (insert line-separator)
+      (insert (format " \"decimal-digit-value\":  %S"
+                     value))
       (setq attributes (delq 'decimal-digit-value attributes))
       (when (and (memq 'digit-value attributes)
                 (setq value (get-char-attribute char 'digit-value)))
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
-       (insert (format "{\"digit-value\":\t  %S}%s"
-                       value
-                       line-breaking))
+       (insert line-separator)
+       (insert (format " \"digit-value\":\t    %S"
+                       value))
        (setq attributes (delq 'digit-value attributes))
        )
       (when (and (memq 'numeric-value attributes)
                 (setq value (get-char-attribute char 'numeric-value)))
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
-       (insert (format "{\"numeric-value\":\t  %S}%s"
-                       value
-                       line-breaking))
+       (insert line-separator)
+       (insert (format " \"numeric-value\":\t    %S"
+                       value))
        (setq attributes (delq 'numeric-value attributes))
        )
       )
      (t
       (when (and (memq 'digit-value attributes)
                 (setq value (get-char-attribute char 'digit-value)))
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
-       (insert (format "{\"digit-value\":\t %S}%s"
-                       value
-                       line-breaking))
+       (insert line-separator)
+       (insert (format " \"digit-value\":\t %S"
+                       value))
        (setq attributes (delq 'digit-value attributes))
        )
       (when (and (memq 'numeric-value attributes)
                 (setq value (get-char-attribute char 'numeric-value)))
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
-       (insert (format "{\"numeric-value\":\t %S}%s"
-                       value
-                       line-breaking))
+       (insert line-separator)
+       (insert (format " \"numeric-value\":\t %S"
+                       value))
        (setq attributes (delq 'numeric-value attributes))
        )))
     (when (and (memq 'iso-10646-comment attributes)
               (setq value (get-char-attribute char 'iso-10646-comment)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format "{\"iso-10646-comment\":\t %S}%s"
                      value
                      line-breaking))
       )
     (when (and (memq 'morohashi-daikanwa attributes)
               (setq value (get-char-attribute char 'morohashi-daikanwa)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format "{\"morohashi-daikanwa\":\t%s}%s"
                      (mapconcat (function prin1-to-string) value " ")
                      line-breaking))
     (when (and (memq 'ideographic-radical attributes)
               (setq value (get-char-attribute char 'ideographic-radical)))
       (setq radical value)
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format " \"ideographic-radical\": %S,\t\"_comment\": \"%c\""
                      radical
                      (ideographic-radical radical)
       )
     (when (and (memq 'shuowen-radical attributes)
               (setq value (get-char-attribute char 'shuowen-radical)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
-      (insert (format "{\"shuowen-radical\":\t %S},\t\"_comment\": \"%c\"%s"
+      (insert line-separator)
+      (insert (format " \"shuowen-radical\":\t %S,\t\"_comment\": \"%c\""
                      value
-                     (shuowen-radical value)
-                     line-breaking))
+                     (shuowen-radical value)))
       (setq attributes (delq 'shuowen-radical attributes))
       )
     (let (key)
        (when (and (memq key attributes)
                   (setq value (get-char-attribute char key)))
          (setq radical value)
-         (if line-separator
-             (insert line-separator)
-           (setq line-separator (format ",%s" line-breaking)))
+         (insert line-separator)
          (insert (format "{\"%s\": %S},\t\"_comment\": \"%c\"%s"
                          key
                          radical
        (when (and (memq key attributes)
                   (setq value (get-char-attribute char key)))
          (setq strokes value)
-         (if line-separator
-             (insert line-separator)
-           (setq line-separator (format ",%s" line-breaking)))
+         (insert line-separator)
          (insert (format " \"%s\": %S"
                          key
                          strokes))
        (setq key (intern (format "%s@%s" 'total-strokes domain)))
        (when (and (memq key attributes)
                   (setq value (get-char-attribute char key)))
-         (if line-separator
-             (insert line-separator)
-           (setq line-separator (format ",%s" line-breaking)))
+         (insert line-separator)
          (insert (format " \"%s\":       %S"
                          key
                          value
          (setq key (intern (format "%s@%s*sources" feature domain)))
          (when (and (memq key attributes)
                     (setq value (get-char-attribute char key)))
-           (if line-separator
-               (insert line-separator)
-             (setq line-separator (format ",%s" line-breaking)))
+           (insert line-separator)
            (insert (format " \"%s\":%s" key line-breaking))
            (dolist (cell value)
              (insert (format " %s" cell)))
     (when (and (memq 'ideographic-strokes attributes)
               (setq value (get-char-attribute char 'ideographic-strokes)))
       (setq strokes value)
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format " \"ideographic-strokes\": %S"
                      strokes
                      ))
     (when (and (memq 'kangxi-radical attributes)
               (setq value (get-char-attribute char 'kangxi-radical)))
       (unless (eq value radical)
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
+       (insert line-separator)
        (insert (format "{\"kangxi-radical\":\t%S},\t\"_comment\": \"%c\"%s"
                        value
                        (ideographic-radical value)
     (when (and (memq 'kangxi-strokes attributes)
               (setq value (get-char-attribute char 'kangxi-strokes)))
       (unless (eq value strokes)
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
+       (insert line-separator)
        (insert (format "{\"kangxi-strokes\":\t%S}%s"
                        value
                        line-breaking))
            (setq strokes value)))
       (setq attributes (delq 'kangxi-strokes attributes))
       )
-    (when (and (memq 'japanese-radical attributes)
-              (setq value (get-char-attribute char 'japanese-radical)))
-      (unless (eq value radical)
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
-       (insert (format "{\"japanese-radical\":\t%S},\t\"_comment\": \"%c\"%s"
-                       value
-                       (ideographic-radical value)
-                       line-breaking))
-       (or radical
-           (setq radical value)))
-      (setq attributes (delq 'japanese-radical attributes))
-      )
     (when (and (memq 'japanese-strokes attributes)
               (setq value (get-char-attribute char 'japanese-strokes)))
       (unless (eq value strokes)
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
+       (insert line-separator)
        (insert (format "{\"japanese-strokes\":\t%S}%s"
                        value
                        line-breaking))
       )
     (when (and (memq 'cns-radical attributes)
               (setq value (get-char-attribute char 'cns-radical)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format "{\"cns-radical\":\t%S},\t\"_comment\": \"%c\"%s"
                      value
                      (ideographic-radical value)
     (when (and (memq 'cns-strokes attributes)
               (setq value (get-char-attribute char 'cns-strokes)))
       (unless (eq value strokes)
-       (if line-separator
-           (insert line-separator)
-         (setq line-separator (format ",%s" line-breaking)))
+       (insert line-separator)
        (insert (format "{\"cns-strokes\":\t%S}%s"
                        value
                        line-breaking))
            (setq strokes value)))
       (setq attributes (delq 'cns-strokes attributes))
       )
-    (when (and (memq 'ideographic- attributes)
-              (setq value (get-char-attribute char 'ideographic-)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
-      (insert "{\"ideographic-\":       ")
-      (setq lbs (concat "\n" (make-string (current-column) ?\ ))
-           separator nil)
-      (while (consp value)
-       (setq cell (car value))
-       (if (integerp cell)
-           (setq cell (decode-char '=ucs cell)))
-       (cond ((characterp cell)
-              (if separator
-                  (insert lbs))
-              (if readable
-                  (insert (format "%S" cell))
-                (char-db-json-insert-char-spec cell readable))
-              (setq separator lbs))
-             ((consp cell)
-              (if separator
-                  (insert lbs))
-              (if (consp (car cell))
-                  (char-db-json-insert-char-spec cell readable)
-                (char-db-json-insert-char-reference cell readable))
-              (setq separator lbs))
-             (t
-              (if separator
-                  (insert separator))
-              (insert (prin1-to-string cell))
-              (setq separator " ")))
-       (setq value (cdr value)))
-      (insert " }")
-      (insert line-breaking)
-      (setq attributes (delq 'ideographic- attributes)))
     (when (and (memq 'total-strokes attributes)
               (setq value (get-char-attribute char 'total-strokes)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
+      (insert line-separator)
       (insert (format " \"total-strokes\":       %S"
                      value
                      ))
       (setq attributes (delq 'total-strokes attributes))
       )
-    (when (and (memq '->ideograph attributes)
-              (setq value (get-char-attribute char '->ideograph)))
-      (if line-separator
-         (insert line-separator)
-       (setq line-separator (format ",%s" line-breaking)))
-      (insert (format "{\"->ideograph\":\t%s}%s"
-                     (mapconcat (lambda (code)
-                                  (cond ((symbolp code)
-                                         (symbol-name code))
-                                        ((integerp code)
-                                         (format "#x%04X" code))
-                                        (t
-                                         (format "%s %S"
-                                                 line-breaking code))))
-                                value " ")
-                     line-breaking))
-      (setq attributes (delq '->ideograph attributes))
-      )
     (if (equal (get-char-attribute char '->titlecase)
               (get-char-attribute char '->uppercase))
        (setq attributes (delq '->titlecase attributes)))
               (setq name (charset-name ret))
               (when (not (memq name dest-ccss))
                 (setq dest-ccss (cons name dest-ccss))
-                (if line-separator
-                    (insert line-separator)
-                  (setq line-separator (format ",%s" line-breaking)))
+                (insert line-separator)
                 (char-db-json-insert-ccs-feature name value line-breaking))
               )
              ((string-match "^=>ucs@" (symbol-name name))
-              (if line-separator
-                  (insert line-separator)
-                (setq line-separator (format ",%s" line-breaking)))
-              (insert (format "{\"%-18s\": #x%04X},\t\"_comment\": \"%c\"%s"
+              (insert line-separator)
+              (insert (format "{\"%-20s\": #x%04X},\t\"_comment\": \"%c\"%s"
                               name value (decode-char '=ucs value)
                               line-breaking))
               )
              ((eq name 'jisx0208-1978/4X)
-              (if line-separator
-                  (insert line-separator)
-                (setq line-separator (format ",%s" line-breaking)))
-              (insert (format "{\"%-18s\": #x%04X}%s"
+              (insert line-separator)
+              (insert (format "{\"%-20s\": #x%04X}%s"
                               name value
                               line-breaking))
               )
               )
              ((or (eq name 'ideographic-structure)
                   (eq name 'ideographic-combination)
-                  (eq name 'ideographic-)
+                   ;; (eq name 'ideographic-)
                   (eq name '=decomposition)
                   (char-feature-base-name= '=decomposition name)
                   (char-feature-base-name= '=>decomposition name)
                   (string-match "^\\(->\\|<-\\)[^*]*\\*sources$"
                                 (symbol-name name))
                   )
-              (if line-separator
-                  (insert line-separator)
-                (setq line-separator (format ",%s" line-breaking)))
+              (insert line-separator)
               (char-db-json-insert-relation-feature char name value
                                                     line-breaking
                                                     ccss readable))
-             ((memq name '(ideograph=
-                           original-ideograph-of
-                           ancient-ideograph-of
-                           vulgar-ideograph-of
-                           wrong-ideograph-of
-                           ;; simplified-ideograph-of
-                           ideographic-variants
-                           ;; ideographic-different-form-of
-                           ))
-              (if line-separator
-                  (insert line-separator)
-                (setq line-separator (format ",%s" line-breaking)))
-              (insert (format "{\"%-18s\":%s " name line-breaking))
-              (setq lbs (concat "\n" (make-string (current-column) ?\ ))
-                    separator nil)
-              (while (consp value)
-                (setq cell (car value))
-                (if (and (consp cell)
-                         (consp (car cell)))
-                    (progn
-                      (if separator
-                          (insert lbs))
-                      (char-db-json-insert-alist cell readable)
-                      (setq separator lbs))
-                  (if separator
-                      (insert separator))
-                  (insert (prin1-to-string cell))
-                  (setq separator " "))
-                (setq value (cdr value)))
-              (insert " }")
-              (insert line-breaking))
              ((consp value)
-              (if line-separator
-                  (insert line-separator)
-                (setq line-separator (format ",%s" line-breaking)))
-              (insert (format "{\"%-18s\": " name))
+              (insert line-separator)
+              (insert (format " %-20s [ "
+                              (format "\"%s\":" name)))
               (setq lbs (concat "\n" (make-string (current-column) ?\ ))
                     separator nil)
               (while (consp value)
                   (insert ret)
                   (setq separator " "))
                 (setq value (cdr value)))
-              (insert " }")
-              (insert line-breaking))
+              (insert " ]")
+              )
              (t
-              (if line-separator
-                  (insert line-separator)
-                (setq line-separator (format ",%s" line-breaking)))
-              (insert (format "{\"%-18s\":" name))
+              (insert line-separator)
+              (insert (format " %-20s "
+                              (format "\"%s\":" name)))
               (setq ret (prin1-to-string value))
               (unless (< (+ (current-column)
                             (length ret)
                             3)
                          76)
                 (insert line-breaking))
-              (insert ret " }" line-breaking)
-              ;; (insert (format "(%-18s . %S)%s"
-              ;;                 name value
-              ;;                 line-breaking))
+              (insert ret)
               )
              ))
       (setq attributes (cdr attributes)))
-    (insert " }")))
+    (insert "\n" (make-string column ?\ ) "}")))
 
 (defun char-db-json-char-data (char &optional readable
                                    attributes column)
 ;;;###autoload
 (defun what-char-definition-json (char)
   (interactive (list (char-after)))
-  (let ((buf (get-buffer-create "*Character Description*"))
+  (let ((est-hide-cgi-mode t)
+       (buf (get-buffer-create "*Character Description*"))
        (the-buf (current-buffer))
        (win-conf (current-window-configuration)))
     (pop-to-buffer buf)
     (erase-buffer)
     (condition-case err
        (progn
-         (char-db-json-char-data-with-variant char nil)
+         (char-db-json-char-data-with-variant char 'printable)
          (unless (char-attribute-alist char)
            (insert (format "// = %c\n"
                            (let* ((rest (split-char char))