I got tired of attempting to get shell scripts to produce valid JSON. You’ve likely seen something like this before: echo '{"name":"Jane"}' It gets merrier if an element contains an environment variable: open double, close single, add variable, open single, blergh. A here! script will do it as will a a printf(1), but neither much improve legibility, and if strings contain quotes, it becomes almost
« golang で画像アップロードが簡単に出来る go-imageupload を使ってみた。 | Main | SQLite3でカジュアルにズンドコキヨシ » コマンドラインから JSON を扱うツールとしては jq が一般的ですが、例えば ls を実行した結果を JSON の Array にしたいであったり、コマンドライン引数から簡単に Object を作りたいといった場合には一旦考え込まないといけないくらい使い方が難しかったりします。そんな中でひょいと現れたのが jo です。 GitHub - jpmens/jo: JSON output from a shell JSON output from a shell https://github.com/jpmens/jo 作者である jpmens さんがなぜ jo を作るに至ったかをブログに書いています。 Jan-Piet Mens
2016-09-15 New! この記事で紹介するコマンドの逆変換コマンド(JSONのみ)も作り、記事化しました。次の相手はjoです。 → joコマンドさようなら、俺はパイプが好きだから。PART 1 郵便番号→緯度経度→日の出時刻 コマンド jqやxmllintといったコマンドの使い勝手についカッとなって、独自JSON&XML解析コマンドと、その応用品“getsunrise.sh”を作った。なぜカッとなったのかは次のセクションで言いたい放題することにして、まぁとりあえず遊んでみてもらいたい。 curlとnkfが入っているUNIX環境ならほとんどの環境で動く。もちろん jqとかxmllintとか不要。JSONとXMLの解析はsedやAWKで済ませてる。 なのでこいつをダウンロードして、解凍・実行するだけだ。(コンパイルも不要) $ ./getsunrise.sh 288-0012 2014
jq is written in C and has no runtime dependencies, so it should be possible to build it for nearly any platform. Prebuilt binaries are available for Linux, macOS and Windows. The binaries should just run, but on macOS and Linux you may need to make them executable first using chmod +x jq. jq is licensed under the MIT license. For all of the gory details, read the file COPYING in the source distri
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く