On Friday, October 24, 2014 2:59:12 PM UTC-7, Andy Parker wrote:
>
> On Fri, Oct 24, 2014 at 1:58 PM, Joshua Hoblitt <jhob...@cpan.org 
> <javascript:>> wrote:
>
>> On 10/24/2014 11:49 AM, Wil Cooley wrote:
>> > On the other hand, I'm more likely to try to run grep on the master, 
>> which
>> > does not work well with minimized JSON (I'm clever enough that I can do 
>> it,
>> > but I would curse under my breath at having to do so). (Yes, I could
>> > probably query PuppetDB for these cases, but...)
>>
>> If you haven't already tried it, jgrep (http://jgrep.org/) can be 
>> helpful.
>>
>>
> And if you want a mind warping, but incredibly powerful, tool try out jq (
> http://stedolan.github.io/jq/). I used it to process a directory full of 
> json files into a single file that contained an analysis.
>
> echo *.analysis | xargs cat | jq -s 'map(.[] | 
> select(has("Puppet::Pops::Model::ResourceExpression")) | to_entries) | add 
> | group_by(.key) | map({ "key": .[0] | .key, "value": map(.value) | add }) 
> | from_entries as $expressions | { "expressions": $expressions, 
> "expressions_per_resource": (($expressions | to_entries | map(.value) | 
> add) / ($expressions | .["Puppet::Pops::Model::ResourceExpression"])), 
> "most_common_expressions": $expressions | to_entries | sort_by(.value) | 
> reverse | .[0:9] | map(.key) }'
>  
> Had to echo and cat because there were too many files for the command line.
>

Also, for the simple case of handling compressed JSON, any system with a 
Python interpreter can pretty print with a simple shell command:

    cat fugly.json | python -m json.tool

I agree that looking at condensed JSON is a pain, but it may not be worth 
the performance tradeoffs given there are quick options for pretty printing.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/8ea01240-212c-40c8-ad08-83c59059ea79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to