エンジニアとしての市場価値を測りませんか?PR

企業からあなたに合ったオリジナルのスカウトを受け取って、市場価値を測りましょう

0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

配列っぽい文字列を配列に戻したい

Posted at

配列っぽい文字列を配列に戻したい時にどうしたか備忘録

'["any", "any1", "hoge"]' → ["any", "any1", "hoge"] こうしたい

配列っぽい文字列

foo = '["any", "any1", "hoge"]'
p foo.class

string

これを配列に戻す

require 'json'

foo = '["any", "any1", "hoge"]'
p JSON.parse(foo)

実はほんとに一番やりたかったこと

最終この形式でブラウザに描画したかった

require 'json'

foo = '["any", "any1", "hoge"]'
p JSON.parse(foo).join(', ')

any, any1, hoge

まとめ

なんかもっとピッタリのメソッドありそうだとおもうんですけど
よければいろいろコメントで教えてください

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?