resthttpurl

How should REST API accept boolean values?


Resource 123 has a current configuration state and a default configuration state, and both of these configuration states can be represented by JSON.

A GET request to http://example.com/123/config will return the current configuration state, and a GET request to http://example.com/123/config?reset=true will return the default configuration state.

How should an API interpret boolean values? For instance:


Solution

  • Whichever way you want it to, it's completely up to you as the architect/designer. true/false is the most syntactically correct version, make sure that one works and add the other options as sugar if you want.