Convert 'true' and 'false' to Boolean in query string

4,053 views
Skip to first unread message

Robert Allsopp

unread,
Jan 18, 2015, 5:15:24 PM1/18/15
to expre...@googlegroups.com
Hey, I was wondering if there is an option built into express's query parser to convert all string instances of 'true', 'false', and 'null', into their actual primitive types automatically. I think I can accomplish this with a short recursive middleware function, but it seems like it might be slightly more efficient if the built in parser already did this during the parsing process.

greelgorke

unread,
Jan 19, 2015, 4:19:19 AM1/19/15
to expre...@googlegroups.com
it shouldn't. this conversion is specific to your application. usually you get a null when the value is empty: "?someNull=&foo=bar".

also true and false are specific to your use case. others are often used to the presence of a key, or some will handle 1 and 0 ore whatever.
Reply all
Reply to author
Forward
0 new messages