Issue #8194 has been updated by Luke Kanies.

Daniel Pittman wrote:
> So, this is tied to the network format handling system, which defaults to the 
> dense rendering.  If you ask for JSON format, it would take extra custom code 
> that did the same work as the existing JSON rendering in the NF code, or that 
> reformatted the JSON it got back, neither of which seem ideal.
> 
> If you just wanted this in the :console format, that wouldn't be so bad, but 
> still requires some custom code.
> 
> OTOH, if we change the default format in the NF code to be pretty-printed, it 
> doesn't much change the equation for machines, but does help humans...

I'd prefer to pay the cost of the extra characters in all versions than not 
have this, that's for sure.

In looking at the code, though, all you really need to do is a small amount of 
special-casing of json.  Something like changing this:
<pre>
  def render(result)
    # Invoke the rendering hook supplied by the user, if appropriate.
    if hook = action.when_rendering(render_as.name)
      result = hook.call(result)
    end

    render_as.render(result)
  end
</pre>
to this:
<pre>
  def render(result)
    # Invoke the rendering hook supplied by the user, if appropriate.
    if hook = action.when_rendering(render_as.name)
      result = hook.call(result)
    end

    if render_as.name == :pson
      jj result
    else
      render_as.render(result)
    end
  end
</pre>

This is what my first version of faces did, I think.
----------------------------------------
Bug #8194: Faces should pretty-print json
https://projects.puppetlabs.com/issues/8194

Author: Luke Kanies
Status: Accepted
Priority: High
Assignee: 
Category: usability
Target version: 
Affected Puppet version: 
Keywords: usability
Branch: 


We currently print json in its most dense form, which makes it basically 
useless for human consumption:
<pre>
{"data":{"edges":[{"target":"File[/tmp/foo]","source":"Class[main]"},{"target":"Class[main]","source":"Stage[main]"}],"name":"localhost","resources":[{"exported":false,"line":84,"title":"/tmp/foo","parameters":{"content":"meh","ensure":"present"},"tags":["file","class"],"type":"File","file":"/Users/luke/bin/test.pp"},{"exported":false,"title":"main","parameters":{"name":"main"},"tags":["stage"],"type":"Stage"},{"exported":false,"title":"Settings","tags":["class","settings"],"type":"Class"},{"exported":false,"title":"main","parameters":{"name":"main"},"tags":["class"],"type":"Class"}],"tags":["settings"],"classes":["settings"],"version":1309539501},"metadata":{"api_version":1},"document_type":"Catalog"}
</pre>
We should convert all of these to pretty-printed forms.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to