开发者

Need to format my json output a little better

I'm trying to make a nice representation of the console.log onto the page itself. I have the following:

window.PRINT = function() {
   if(this.console) { 
      console.log( Array.prototype.slice.call(arguments) );
   }

   va开发者_开发问答r X = $('#PRINT');
   if (!X) {
      $('body').append('<p id="PRINT"></p>');
      X = $('#PRINT');
   }
   $.each(arguments, function(Index,  Value) {
      X.append('<p>' + JSON.stringify(Value) + '</p>');
   });
};

The problem is when I use it for

$('input').change(function(myEvent) { 
   PRINT(myEvent,this); 
});

It doesn't really do a very good job of printing out the objects and their contents. I wonder if there's a json formatter somewhere. I'm not talking about a Firefox plugin, I mean: one that accepts json coming in and outputs a nice html representation of it, perhaps.


if you're just looking to visualize JSON use something like

visualizer.json2html.com


Try one of these:

  • JSON2HTML Bloopletech
    • Demo page
  • Zach Hunter's JSON to HTML
    • Demo project (download)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜