Catmandu::Fix::get_json(3pm)

Catmandu::Fix::get_json3pm

Get json data from an url as fix function

Usage

        # fetches a hash or array
        get_json("http://example.com/json")
        # stores it in path.key
        get_json("http://example.com/json", path: path.key)
    # add URL query parameters or URL path from config
        get_json("http://example.com/", vars: config)
    # fill URL template fields from config
        get_json("http://example.com/{name}.json", vars: config)
        # get URL or URL template from a field
        get_json(field.name)

Overview

This Catmandu::Fix provides a method to fetch JSON data from an URL. The response is added as new item or to a field of the current item.

Options

The first argument must be an URL, an URL template, or a field where to take an URL or URL template from. Additional options include:

path

Field to store result JSON in. If not given or set to the empty string, the whole item is replaced by the fetched JSON response. If the first argument is a field, the same field is used as "path" by default.

vars

Field to get URL template variables, URL query parameters or an URL path expression from. This option is required if the first argument is an URL template.

The fix function also supports options "dry", "cache", "timeout", "agent", "proxy", and "wait" as documented in Catmandu::Importer::getJSON. Options "client", "headers", and "warn" are not supported.

Releases

6 releases since Debian 8 (Jessie); the text changed 4 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12–13

From libcatmandu-importer-getjson-perl 0.52-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.