mysql2json - convert mysql -B output to JSON object streams
version 0.005
mysql -B -u user -password -h 10.0.0.5 database \ -e 'select crontab_id, task_id from crontab' | \ mysql2json | jsort -k task_id -rn | head -5
mysql2json(1) reads mysql(1) batch output and writes JSON objects, one per line, corresponding to each database row.
The SYNOPSIS example produces something like this:
{"crontab_id":"102","task_id":"701"} {"crontab_id":"101","task_id":"700"} {"crontab_id":"100","task_id":"650"} {"crontab_id":"8","task_id":"599"} {"crontab_id":"14","task_id":"38"}
You may read this utility's implementation in its entirety at
perldoc -m mysql2json
App::PipeFilter::MysqlToJson implements this utility.
App::PipeFilter has top-level documentation including a table of contents for all the libraries and utilities included in the project.
https://rt.cpan.org/Public/Dist/Display.html?Name=App-PipeFilter
https://github.com/rcaputo/app-pipefilter
mysql2json is Copyright 2011 by Rocco Caputo. All rights are reserved. mysql2json is released under the same terms as Perl itself.
To install App::PipeFilter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::PipeFilter
CPAN shell
perl -MCPAN -e shell install App::PipeFilter
For more information on module installation, please visit the detailed CPAN module installation guide.