Commit 6d78ddcc authored by MORIOKA Tomohiko's avatar MORIOKA Tomohiko
Browse files

(chise-json-encode-object*): Modify for v1; use

(chise-json-encode-string): New function.
(chise-json-char-get-info): Support `ideographic-structure'.
(chise-json-dump-char): Fix duplicated JSON object when generating
root character object.
parent c0fd640b
......@@ -34,14 +34,32 @@
(aref ret 3)
(aref ret 2)
(list '(@type . genre:character)
(cons '@id (chise-rdf-iri-encode-object object))))
(cons '(@type . concord:genre/character)
(chise-json-char-get-ref-info object)))
((concord-object-p object)
(list (cons '@type (format "genre:%s" (concord-object-genre object)))
(list (cons '@type (format "concord:genre/%s" (concord-object-genre object)))
(cons '@id (chise-rdf-iri-encode-object object)))
(defun chise-json-encode-string (string)
(let (ucs ret)
(mapconcat (lambda (object)
(if (setq ucs (encode-char object '=ucs))
(if (<= ucs #xFFFF)
(char-to-string object)
(setq ret (encode-coding-string (char-to-string object)
(format "\\u%2X%02X\\u%02X%02X"
(aref ret 1)
(aref ret 0)
(aref ret 3)
(aref ret 2)
(encode-coding-string (char-to-string object)
string "")))
(defun json-encode (object)
"Return a JSON representation of OBJECT as a string."
(if (or (characterp object)
......@@ -2316,6 +2334,32 @@
(when structure-spec
(setq dest
(mapcar (lambda (cell)
(format "chise:domain/structure/%s" (or (car cell) 'functional))
(setq ret (ideographic-structure-compact
(mapcar #'identity
(cdr (assq 'body (cdr cell))))))
(cons 'ids
(ideographic-structure-to-ids ret)))
(cons 'ideographic-structure ret)
(del-alist 'body (cdr cell))))))
(sort structure-spec
(lambda (a b)
(if (car a)
(if (car b)
(string< (car a)(car b))
(dolist (cell (sort other-spec
(lambda (a b)
(chise-json-normalized-feature< b a))))
......@@ -2497,6 +2541,7 @@
(setq file (expand-file-name "index.jsonld" dir))
(when (or force-rewrite
(not (file-exists-p file)))
(list* '(@context . "")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment