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 5 years have passed since last update.

Javascriptでブランケット付きのURLパラメータをオブジェクトに

Posted at

概要

railsで(たしかPHPも?)foo[bar][quz]=123&foo[bar][qux][]=1みたいなクエリーをつけると

{
  foo: {
    bar: {
      quz: 123,
      quz: [1]
    }
  }
}

というHashが得られますが、それをJavascript側でもオブジェクト化したくて、自分で実装するのも地味に大変そうな気がして探したけど見つけるのに手間取ったので載せておきます。

qs

これで期待通りの結果が得られました。

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?