]> git.kaiwu.me - nginx.git/commit
Added the json parser module
authorRoman Semenov <r.semenov@f5.com>
Wed, 12 Aug 2026 16:52:08 +0000 (09:52 -0700)
committerRoman S <141866642+roman-f5@users.noreply.github.com>
Mon, 24 Aug 2026 18:08:31 +0000 (11:08 -0700)
commita1f4a617699089204a5e76267941ceee844f19ea
tree36da2c31202b87d1251937c51713293b6bdc44a9
parent55db1978e25eb2befd3cd96304f11b5d5cd947c9
Added the json parser module

Added the http_json_module with a json_set directive that
extracts values from JSON stored in nginx variables and exposes them
as new nginx variables.  Parsed results are cached per request, so
multiple json_set directives using the same source expression trigger
only one parse.  The directive is available in the http main context.

Example usage:

    http {
        json_set $user_name $arg_data user.name;
        json_set $user_age  $arg_data user.age;
        json_set $tag0      $arg_data tags[0];

        server {
            listen 8080;

            location / {
                return 200 "name=$user_name age=$user_age "
                           "tag0=$tag0\n";
            }
        }

        # quoted keys for names containing '.', '[', ']', or that
        # are empty; the whole argument is single-quoted so that the
        # inner '"' reach the path parser intact
        json_set $host      $arg_data '["a.b.com"]';
        json_set $nested    $arg_data 'obj["a.b"].c[2]';
        json_set $quoted    $arg_data 'obj["a\\"b"]';
    }

Co-authored-by: Dmitry Volyntsev <d.volyntsev@f5.com>
auto/modules
auto/options
src/http/modules/ngx_http_json_module.c [new file with mode: 0644]