Catman...et_json(3pm)
π Catmandu::Fix::get_json β the manual page, but make it make sense π
okay bestie, you found the get_json page of the Perl docs (that's Catmandu::Fix::get_json, section 3pm), and honestly? it's a lil cutie. it grabs JSON from a URL and drops it right into your item. no cap. let's get into it. β¨
πΈ NAME πΈ
Catmandu::Fix::get_json β get JSON data from an URL as a fix function π¦
π SYNOPSIS π
# 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)
yes the indentation is exactly like that, we don't question the ancestors π
β¨ DESCRIPTION β¨
so this Catmandu::Fix gives you a method to fetch JSON data from an URL. that's it, that's the job. the response gets added as a new item, or dropped into a field of the current item β your choice, you're the main character here π
π₯ OPTIONS π₯
first things first, bestie: the first argument has to be an URL, an URL template, or a field where to take an URL or URL template from. no first argument, no vibes. π
then you've got the extra options:
pathβ the field where the result JSON gets stored. if you don't give it, or you set it to the empty string"", then the whole item gets replaced by the fetched JSON response. and if the first argument is a field, that same field is used aspathby default. cute, right? πvarsβ the field to get URL template variables, URL query parameters, or an URL path expression from. this one is required if your first argument is an URL template. required required. not optional. π«Ά
also, and this is important so don't scroll past it π
the fix function also supports the options dry, cache, timeout, agent, proxy, and wait β all as documented over in Catmandu::Importer::getJSON. go read that one if you need the deets, we're not re-explaining them here, that's their whole page π
and now the part nobody likes: options client, headers, and warn are not supported. nope. not a thing. don't come for me, I don't make the rules π
that's the whole page, bestie, you ate it π β¨
signing off: this was written for perl v5.36.0, dated 2022-12-10, and it lives in the User Contributed Perl Documentation. go forth and fetch that JSON. periodt. πππ¦
π¦ where this page comes from
- debian bookworm: libcatmandu-importer-getjson-perl 0.52-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcatmandu-importer-getjson-perl 0.52-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatmandu-importer-getjson-perl 0.52-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libcatmandu-importer-getjson-perl 0.52-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms