I'm working on an implementation of a webform decoder and am looking to support the nested webform pattern employed by PHP and Ruby/Rails (possibly amongst others).
PHP: parse_str()
; Ruby: Rack::Utils.parse_nested_query()
I've noticed some inconsistencies, for example (behaviour is the same in both languages):
foo=One&foo=Two
=> {'foo':'Two'}
foo[][bar]=One&foo[][bar]=Two
=> {"foo":[{"bar":"One"},{"bar":"Two"}]}
Here identical keys are discarded if at the top-level, but respected if at they exist lower down.
Is the rationale behind this design documented anywhere? Was the Ruby/Rails approach based on the PHP design (or vice-verca)?