When designing a RESTful API that uses JSON to respond to requests, I usually return an object like this when an error happens:{  error: Something bad happened,  error_code: XXX}Do I need to have a error:  or error: null in my object when there is no error? 
Do I need to return error: null in JSON response?
api design;json
If the response is a success, don't include error in your response. Example:GET /product/15406/200 OK{    id: 15406,    name: A cookie with pieces of chocolate,    price: 1.45,    is-available: true}On the other hand, an error would look like:GET /product/nan/403 Forbidden{    error: 5020,    error-message: The specified product identifier cannot be converted to a number.}Notes:Do change the HTTP status code on error. Returning 200 OK when something got wrong is silly.Don't include error fields in the success response. Why would you? You aren't including price or is-available in the erroneous response, are you?Do use strings for text and numbers for numbers. Your error_code: XXX looks like you are putting a number as an error code, but passing it as a string. If it's a number, it should remain a number in the response. Note that using strings as error codes may be a good solution: error 5020 is not extremely explicit; error InvalidProductIdentifier is.