Boolean in a URI query?

Clint picture Clint · Jun 24, 2011 · Viewed 36.5k times · Source

What is the preferred way to specify boolean value in the query part of URI? A normal query string looks like

a=foo&b=bar

Say I have a parameter "c" with boolean value, should I state

a=foo&b=bar&c=1

Or

a=foo&b=bar&c=True

Or

a=foo&b=bar&c=true

I checked the query component section of RFC 2396 and it does not specify how to express a boolean parameter. So what I want to know is what is the common (or reasonable) way to do it?

Answer

Petar Ivanov picture Petar Ivanov · Jun 24, 2011

It completely depends on the way you read the query string. All of these that you ask for are valid.