Git Product home page Git Product logo

Comments (5)

josevalim avatar josevalim commented on June 22, 2024

Thanks for the report. Can we look at other parsers? Do we have use cases where those formats would be used so we can evaluate this based on actual usage patterns?

from plug.

cliftonc avatar cliftonc commented on June 22, 2024

The result of the qs parser (part of the Node eco-system) is this:

{"array":[{"foo":["foo1","foo2"],"bar":"bar2"}]}

If I parsed it 'manually' by reading it I'd expect this result. The fact that foo1 and foo2 are both values of [][foo] mean they should be together as elements in the foo array, bar is separate.

from plug.

whatyouhide avatar whatyouhide commented on June 22, 2024

Should we test as many parsers as we can and try to adapt to the most common behaviour or just leave the parser as is? I feel this issue is an easy one once we understand what should be done 😸.

from plug.

josevalim avatar josevalim commented on June 22, 2024

Thanks everyone!

So, I don't agree with node's result because I would expect to achieve that if I had this:

/?array[][foo][]=foo1&array[][foo][]=foo2&array[][bar]=bar2

For example, that's exactly what I get by serialising the value back to param using jQuery:

> decodeURIComponent(jQuery.param({"array":[{"foo":["foo1","foo2"],"bar":"bar2"}]}))
"array[0][foo][]=foo1&array[0][foo][]=foo2&array[0][bar]=bar2"

I don't seem to find any consensus here. jQuery will serialize arrays only if you have string. Check this out:

decodeURIComponent(jQuery.param({"array":[{"foo": "foo"}, "bar2"]}))
"array[0][foo]=foo&array[]=bar2"

Because the first element of the array is an object, it actually indexed it as array[0]. So it seems what we are trying to discuss will never be generated by jQuery and it is hard to come up with any conclusion unless we discuss how and why this is being generated.

from plug.

josevalim avatar josevalim commented on June 22, 2024

I am closing this. Once we have real data and real forms we can always reopen and rediscuss!

from plug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.