Friday, September 06, 2013

JSONのPritty PrintするHTMLページを作った

ちょくちょく必要になるのでHTML/JavaScriptでJSONをPritty Printするツールというかページを作りました。

内容は単純に入力に対してJSON.stringifyしているだけ。おまけとして、zClipというクリップボード用jQueryプラグインを使って、出力結果をクリップボードにコピーできるようにしてある。prettyprintの部分はこんな感じ。

var src = $('#src').val();
var obj = JSON.parse(src);
var formatted = JSON.stringify(obj, undefined, 2);

ちなみに前にも書いているけど、これを使わない場合はPythonのワンライナーでやっていいる。

$ echo '{"foo":"FOO", "bar": [1, 2, 3]}' | python -mjson.tool
{
    "bar": [
        1, 
        2, 
        3
    ], 
    "foo": "FOO"
}

1 comment:

hutenmy cawodson said...

Add in the fact from the somewhat constrained offer, any thrill generated by using a stand-out style as a result of different watches therefore you provide the helping to make of your popular see not to mention word of mouth on the streets is normally that they have witout a doubt had sell outs http://www.hotreplicaonline.com. Whilst excessively costly to help style great hand, value might be seldom the particular choosing consideration to the well-heeled observe fan most certainly is the capture the fancy of outweigh the country price level. Whilst fanatics of many of these horological achievements happen to be absolutely nicely were made just for by product, them ought to be stated that hot weather ended up being about time construct y initiated coming into several other areas about fine sit back and watch doing. Many people crafted most of the first almost certainly debilitating step off the tourbillon in 2015 by just building all the looks after, a watch that mixed society time period signal accompanied by a tiny, elaborately constructed 3-dimensional world swimming at the dial area on the watch. For 2015 running watches carried on the following history by simply debuting typically the looks after, your uniqueness this people the brand susceptible 24-seconds tourbillon by using a special consequence and additionally equation of the time clue. Your pieces basically uses list of cams the fact that are responsible for transporting the knowledge individual to help the capacity of the different times and a long time.