Giter Site home page Giter Site logo

Comments (10)

dougwilson avatar dougwilson commented on March 28, 2024

I think we can easily add this as the option to accept a string in the options object and just provide that string to type-is.

from body-parser.

Fishrock123 avatar Fishrock123 commented on March 28, 2024

I'm not 100% sure how type-is works, but I think that would mean the new string would become the only correct JSON type.

Imo, the easiest and best way to fix this is just like /json/.test(req.headers['content-type']).

from body-parser.

dougwilson avatar dougwilson commented on March 28, 2024

That is how type-is works, but it's perfectly fine. If you want to parse both application/json and application/vnd.api+json you would just do:

app.use(bodyParser.json())
app.use(bodyParser.json({type: 'application/vnd.api+json'}))

Using a parser for each type also would let the user do stuff like giving a different reviver per type.

from body-parser.

Fishrock123 avatar Fishrock123 commented on March 28, 2024

+1 didn't really know you could do that.

from body-parser.

diosney avatar diosney commented on March 28, 2024

@dougwilson: Neat! I like the new way :) Thanks!

When this feature will be get published in the npm registry?

from body-parser.

dougwilson avatar dougwilson commented on March 28, 2024

When this feature will be get published in the npm registry?

As soon as I can, so probably today some time. I like to let the potential release sit a bit before hitting "publish" so I can think on it and prevent some dumb mistake :)

from body-parser.

Fishrock123 avatar Fishrock123 commented on March 28, 2024

Also gives time for people (read: me) to land doc nits before the next release hah. :P

from body-parser.

dougwilson avatar dougwilson commented on March 28, 2024

@Fishrock123 I saw that commit, haha.

from body-parser.

dougwilson avatar dougwilson commented on March 28, 2024

@diosney published as 1.1.0

from body-parser.

diosney avatar diosney commented on March 28, 2024

@dougwilson Thanks! I already tested it and worked like a charm. :)

Thanks again for your hard work :)

from body-parser.

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.