Giter Site home page Giter Site logo

Comments (5)

nlf avatar nlf commented on April 27, 2024

Currently, that is the intended behavior, yes.

If there's a strong opinion to not have this behavior, I'm open to hearing it.

@dougwilson maybe you have some input here?

from qs.

dougwilson avatar dougwilson commented on April 27, 2024

Because urlencoded is not as rich as JSON and things, it doesn't have a lot of different types. Everything is just a string, so nothing to the right of the equal sign is an empty string. If it were up to me, for the example above [] doesn't make sense at all. The best outcomes would be [''], [undefined], or [null], but all those are weird. Ideally you should be able to take come input and get str === qs.stringify(qs.parse(str)) (excluding encoding differences).

Looking at the results of qs.parse(qs.stringify(obj)), it seems [''] or [null] both fit the bill. I'm am not decided yet on which one seem better :)

from qs.

nlf avatar nlf commented on April 27, 2024

Yeah, my instinct is to keep the empty string. It doesn't feel 100% right, but it's just as close to right as anything else I can think of.

from qs.

dougwilson avatar dougwilson commented on April 27, 2024

Yep. The empty array may have been what the old qs did, but it feels wrong and I know it caused problems when people expected "name[]=first&name[]=&name[]=last" to return three elements because someone left middle blank in an input field.

from qs.

nlf avatar nlf commented on April 27, 2024

Going to close this, I think the current behavior is the closest to appropriate we'll get.

from qs.

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.