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 'http://search.twitter.com/search.json?q=pipefilters' |
jpath -o '$..from_user' -o '$..text' |
jmap -i col0 -o from -i col1 -o text |
json2yaml

... produces output like this:

--- 
from: perlironman
text: "Rocco Caputo (rcaputo): App::PipeFilters - JSON in the Shell http://bit.ly/mGgnOX"

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 'http://api.duckduckgo.com/?q=poe&o=json' |
jpath −o '$..Topics.*.FirstURL' −o '$..Topics.*.Text' |
grep −i perl |
jmap −i col0 −o url −i col1 −o title |
json2yaml

... produces:

−−−
title: Perl Object Environment, a library for event driven multitasking for the Perl programming language
url: http://duckduckgo.com/Perl_Object_Environment

Leave a comment

About Rocco Caputo

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