Skip to content

Commit ea380ea

Browse files
ahwattsgongo
authored andcommitted
json-reformat:print-node: json-read-from-string with a plist will reverse the order of the attributes it reads. Reverse the plist to maintain the order.
1 parent 69a344b commit ea380ea

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

json-reformat.el

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,18 @@
7272
"\n" (json-reformat:indent level) "]"
7373
)))
7474

75+
(defun json-reformat:reverse-plist (val)
76+
(let ((root val) rval)
77+
(while root
78+
(let ((key (car root))
79+
(val (cadr root)))
80+
(setq root (cddr root))
81+
(setq rval (cons val rval))
82+
(setq rval (cons key rval))))
83+
rval))
84+
7585
(defun json-reformat:print-node (val level)
76-
(cond ((consp val) (json-reformat:tree-to-string val level))
86+
(cond ((consp val) (json-reformat:tree-to-string (json-reformat:reverse-plist val) level))
7787
((numberp val) (json-reformat:number-to-string val))
7888
((vectorp val) (json-reformat:vector-to-string val level))
7989
((null val) "null")

0 commit comments

Comments
 (0)