Is it appropriate to return an empty JSON structure when no data is available? I feel that it is slightly ambiguous.
I have a server-side interface that allows a client to request some information about a particular stock ticker, and the information (e.g. stock quotes) is returned as JSON. The client will use e.g.
$.getJSON( "http://some.url/stock.json?ticker=MSFT", function( data ) { ...
to get information about Microsoft stock.
Now, what if I have no information about a particular stock? Is it cleaner to return an empty JSON structure or should it be HTTP 404? If I return an empty JSON, does it mean that there is no such ticker at all, if e.g. the client requested http://some.url/stock.json?ticker=ANOTHERMSFT
, or that simply there is no data for a particular ticker? I am the one implementing the client, so it doesn't matter that much; just curious, what is a better approach and why.