Add support for JSON pretty printing

The monitor does not pretty-print JSON output, so that everything
will be on a single line reply. When JSON docs get large this is
quite unpleasant to read. For the future command line capabilities
query ability, huge JSON docs will be available. This needs the
ability to pretty-print.

This introduces a new API qobject_to_json_pretty() that does
a minimal indentation of list and dict members. As an example,
this makes

  {"QMP": {"version": {"micro": 50, "minor": 12, "package": "", "major": 0}, "capabilities": []}}

Output as

  {
      "QMP": {
          "version": {
              "micro": 50,
              "minor": 12,
              "package": "",
              "major": 0
          },
          "capabilities": [
          ]
      }
  }

NB: this is not turned on for the QMP monitor.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2 files changed
tree: 9f2b979a0310597e8e49c296fd36b29b79415354
  1. audio/
  2. block/
  3. bsd-user/
  4. darwin-user/
  5. default-configs/
  6. docs/
  7. fpu/
  8. fsdev/
  9. gdb-xml/
  10. hw/
  11. linux-user/
  12. net/
  13. pc-bios/
  14. QMP/
  15. roms/
  16. slirp/
  17. sysconfigs/
  18. target-alpha/
  19. target-arm/
  20. target-cris/
  21. target-i386/
  22. target-m68k/
  23. target-microblaze/
  24. target-mips/
  25. target-ppc/
  26. target-s390x/
  27. target-sh4/
  28. target-sparc/
  29. tcg/
  30. tests/
  31. ui/
  32. .gitignore
  33. .gitmodules
  34. a.out.h
  35. acl.c
  36. acl.h
  37. aes.c
  38. aes.h
  39. aio.c
  40. alpha-dis.c
  41. alpha.ld
  42. arch_init.c
  43. arch_init.h
  44. arm-dis.c
  45. arm-semi.c
  46. arm.ld
  47. async.c
  48. balloon.c
  49. balloon.h
  50. block-migration.c
  51. block-migration.h
  52. block.c
  53. block.h
  54. block_int.h
  55. blockdev.c
  56. blockdev.h
  57. bswap.h
  58. bt-host.c
  59. bt-host.h
  60. bt-vhci.c
  61. buffered_file.c
  62. buffered_file.h
  63. cache-utils.c
  64. cache-utils.h
  65. Changelog
  66. check-qdict.c
  67. check-qfloat.c
  68. check-qint.c
  69. check-qjson.c
  70. check-qlist.c
  71. check-qstring.c
  72. cmd.c
  73. cmd.h
  74. CODING_STYLE
  75. config.h
  76. configure
  77. console.c
  78. console.h
  79. COPYING
  80. COPYING.LIB
  81. cpu-all.h
  82. cpu-common.h
  83. cpu-defs.h
  84. cpu-exec.c
  85. cpus.c
  86. cpus.h
  87. create_config
  88. cris-dis.c
  89. cursor.c
  90. cursor_hidden.xpm
  91. cursor_left_ptr.xpm
  92. cutils.c
  93. def-helper.h
  94. device_tree.c
  95. device_tree.h
  96. dis-asm.h
  97. disas.c
  98. disas.h
  99. dma-helpers.c
  100. dma.h
  101. dyngen-exec.h
  102. elf.h
  103. envlist.c
  104. envlist.h
  105. exec-all.h
  106. exec.c
  107. feature_to_c.sh
  108. gdbstub.c
  109. gdbstub.h
  110. gen-icount.h
  111. HACKING
  112. host-utils.c
  113. host-utils.h
  114. hpet.h
  115. hppa-dis.c
  116. hppa.ld
  117. hxtool
  118. i386-dis.c
  119. i386.ld
  120. ia64-dis.c
  121. ia64.ld
  122. input.c
  123. ioport-user.c
  124. ioport.c
  125. ioport.h
  126. iov.c
  127. iov.h
  128. json-lexer.c
  129. json-lexer.h
  130. json-parser.c
  131. json-parser.h
  132. json-streamer.c
  133. json-streamer.h
  134. kvm-all.c
  135. kvm-stub.c
  136. kvm.h
  137. libfdt_env.h
  138. LICENSE
  139. linux-aio.c
  140. m68k-dis.c
  141. m68k-semi.c
  142. m68k.ld
  143. MAINTAINERS
  144. Makefile
  145. Makefile.dis
  146. Makefile.hw
  147. Makefile.objs
  148. Makefile.target
  149. Makefile.user
  150. microblaze-dis.c
  151. migration-exec.c
  152. migration-fd.c
  153. migration-tcp.c
  154. migration-unix.c
  155. migration.c
  156. migration.h
  157. mips-dis.c
  158. mips.ld
  159. module.c
  160. module.h
  161. monitor.c
  162. monitor.h
  163. nbd.c
  164. nbd.h
  165. net-checksum.c
  166. net.c
  167. net.h
  168. notify.c
  169. notify.h
  170. os-posix.c
  171. os-win32.c
  172. osdep.c
  173. osdep.h
  174. path.c
  175. pci-ids.txt
  176. poison.h
  177. posix-aio-compat.c
  178. ppc-dis.c
  179. ppc.ld
  180. ppc64.ld
  181. qbool.c
  182. qbool.h
  183. qdict-test-data.txt
  184. qdict.c
  185. qdict.h
  186. qemu-aio.h
  187. qemu-barrier.h
  188. qemu-binfmt-conf.sh
  189. qemu-char.c
  190. qemu-char.h
  191. qemu-common.h
  192. qemu-config.c
  193. qemu-config.h
  194. qemu-doc.texi
  195. qemu-error.c
  196. qemu-error.h
  197. qemu-img-cmds.hx
  198. qemu-img.c
  199. qemu-img.texi
  200. qemu-io.c
  201. qemu-lock.h
  202. qemu-log.h
  203. qemu-malloc.c
  204. qemu-monitor.hx
  205. qemu-nbd.c
  206. qemu-nbd.texi
  207. qemu-objects.h
  208. qemu-option.c
  209. qemu-option.h
  210. qemu-options.h
  211. qemu-options.hx
  212. qemu-os-posix.h
  213. qemu-os-win32.h
  214. qemu-queue.h
  215. qemu-sockets.c
  216. qemu-tech.texi
  217. qemu-thread.c
  218. qemu-thread.h
  219. qemu-timer.c
  220. qemu-timer.h
  221. qemu-tool.c
  222. qemu-x509.h
  223. qemu.sasl
  224. qemu_socket.h
  225. qerror.c
  226. qerror.h
  227. qfloat.c
  228. qfloat.h
  229. qint.c
  230. qint.h
  231. qjson.c
  232. qjson.h
  233. qlist.c
  234. qlist.h
  235. qobject.h
  236. qstring.c
  237. qstring.h
  238. range.h
  239. readline.c
  240. readline.h
  241. README
  242. rules.mak
  243. rwhandler.c
  244. rwhandler.h
  245. s390-dis.c
  246. s390.ld
  247. savevm.c
  248. sh4-dis.c
  249. simpletrace.c
  250. simpletrace.h
  251. simpletrace.py
  252. softmmu-semi.h
  253. softmmu_defs.h
  254. softmmu_exec.h
  255. softmmu_header.h
  256. softmmu_template.h
  257. sparc-dis.c
  258. sparc.ld
  259. sparc64.ld
  260. sysemu.h
  261. targphys.h
  262. tcg-runtime.c
  263. texi2pod.pl
  264. thunk.c
  265. thunk.h
  266. TODO
  267. trace-events
  268. tracetool
  269. translate-all.c
  270. uboot_image.h
  271. usb-bsd.c
  272. usb-linux.c
  273. usb-stub.c
  274. VERSION
  275. version.rc
  276. vgafont.h
  277. vl.c
  278. x86_64.ld