付きオブジェクトを作成するには、application/x-www-form-urlencoded
として又はapplication/json
のいずれかとデータ掲載することにより、新しいオブジェクトを作成することができる:/ディンゴ形式でエンコードされたドット路特性
$ curl -XPOST --data name=foo http://example.org/user
JSON:
$ curl -XPOST -H 'Content-type: application/json' --data '{"name":"foo"}' http://example.org/user
両方をうまく動作します。
ここでは、ネストされたプロパティを持つオブジェクトを作成します。 name.first
。
$ curl -XPOST -H 'Content-type: application/json' --data '{"name":{"first:"foo"}}' http://example.org/user
しかし、それは形式でエンコードされたデータを用いたときに失敗します:JSONを投稿するときはこれが正常に動作します
$ curl -XPOST --data name.first=foo http://example.org/user
を例外はThe name.first field is required
です。
PHP自動的にアンダースコアの着信変数名にドットを置き換えます:。私はPHP converts dots to underscoresがあることを知っている
これは、laravelが変数をネストされたものとして検出しない可能性があるためです。
laravelで変数名のドットパスを正しく検出できるようにするにはどうすればよいですか?