I’ve created a template that outputs JSON like this:
[
{exp:mylib:mytag channel="mychannel" backspace="1"}
{"entry_id":"{entry_id}","title":"{title}"},
{/exp:mylib:mytag}
]It works fine when mytag returns data. The response is, e.g.:
[{"entry_id":"252","title":"mytitle1"}, {"entry_id":"218","title":"mytitle2"}]When the tag returns no entries, I expect the template to output just
[]. Unfortunately I’m not getting that, I get nothing back from EE at all: zero bytes. When I point the a web browser at the URL the same thing happens.
EDIT: A static .html file served from the same Apache server/virtual host does send empty square brackets, so it’s not just a quirk of the web server.
Please don’t suggest that I use one of the existing json modules (I already am for some stuff), I’d like to know the principle of why EE doesn’t treat this template the way I expect. The way one learns is by understanding, not by implementing non-fixes.