LoginSignup
1
1

More than 5 years have passed since last update.

エスケープされたJSON文字列をrubyのワンライナーで雑にパースする方法

Last updated at Posted at 2016-08-22

自分用メモ

# 普通のJSON文字列
echo '{"key1":"value1","key2":"value2"}' | ruby -r json -ne 'json = JSON.parse($_); puts json["key1"]' # => value1

# エスケープされてる場合
echo '"{\"key1\":\"value1\",\"key2\":\"value2\"}"' | ruby -r json -ne 'json = JSON.parse(eval($_)); puts json["key1"]' # => value1

ruby: 2.3.1

1
1
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1