App::PipeFilters gets multiline parsing and JSON::Path

Tonight I added support for multiline JSON input to all the App::PipeFilter tools. This is great for data sources that are beyond one's control, such as those found on the web. But I haven't found one to use as an example, so you get this instead:

% curl -s '' |
jpath -o '$..from_user' -o '$..text' |
jmap -i col0 -o from -i col1 -o text |

... produces output like this:

from: perlironman
text: "Rocco Caputo (rcaputo): App::PipeFilters - JSON in the Shell"

See what I did there with JSON::Path expressions? The jpath filter can extract fields from deep within JSON objects (but jcut will be faster for simple JSON objects).

Here's another example:

% curl −s '' |
jpath −o '$..Topics.*.FirstURL' −o '$..Topics.*.Text' |
grep −i perl |
jmap −i col0 −o url −i col1 −o title |

... produces:

title: Perl Object Environment, a library for event driven multitasking for the Perl programming language

Leave a comment

About Rocco Caputo

user-pic Among other things I write software, a lot of which is in Perl.