[master] e0b9077 Add support for JSON CLI responses.

Poul-Henning Kamp phk at phk.freebsd.dk
Thu Feb 4 10:14:06 CET 2016


Kristian prodded me for this, and I decided to get this moving
right away, because somebody else™ will have to do the work of
actually writing the functions to emit JSON for the relevant
commands.

To get consistency in the output/structure/pathology of the resulting
JSON, I'm appointing Kristian as our "JSON-Czar", (Subject to appeal
to me, if he starts to demand Unicode emoticons etc.)

See VCLS_func_help_json() for some hints.

Be aware that the -j is passed to the json functions.

Please always use the VCLI_JSON_ver() function.  The version number
is per-command. (The reason the call is conditional in 'help' is to
deal with being called both from the master and the slave.

Poul-Henning

commit e0b9077c87b683a12af45daaf8c08ab4e7ce4195
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Feb 4 01:51:05 2016 +0000

    Add support for JSON CLI responses.
    
    To get JSON back, the first argument must be "-j".
    
    Currently only "help -j" is implemented, but that
    will helpfully tell you which commands support
    json output.
    
    All JSON output has the form:
    
        [ version#, [<cli_command>],
                stuff
        ]
    
    For instance:
    
        [ 1, ["help", "-j"],
          {
          "request": "help",
          "syntax": "help [<command>]",
          "help": "\tShow command/protocol help.",
          "minarg": 0, "maxarg": 1, "flags": "", "json": true
          },
          {
          "request": "ping",
          "syntax": "ping [<timestamp>]",
          "help": "\tKeep connection alive.",
          "minarg": 0, "maxarg": 1, "flags": "", "json": false
          },
          ...
        ]
    
    The string quoting for weird characters in JSON is XXX incomplete.


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.



More information about the varnish-dev mailing list