2
0
Эх сурвалжийг харах

qmp-shell: Sort by key when pretty-printing

If the user selects pretty-printing (-p) the contents of any
dictionaries in the output are sorted by key.

Signed-off-by: David Edmondson <david.edmondson@oracle.com>
Message-Id: <20201013141414.18398-1-david.edmondson@oracle.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
David Edmondson 4 жил өмнө
parent
commit
fca9d72323

+ 1 - 1
scripts/qmp/qmp-shell

@@ -260,7 +260,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
         indent = None
         indent = None
         if self._pretty:
         if self._pretty:
             indent = 4
             indent = 4
-        jsobj = json.dumps(qmp, indent=indent)
+        jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty)
         print(str(jsobj))
         print(str(jsobj))
 
 
     def _execute_cmd(self, cmdline):
     def _execute_cmd(self, cmdline):