Freemarker, list index and count condition
Try with item_has_next
In your example:
<#if pages_has_next>,</#if>
Index has to be prefixed with your item name. In example:
<#if (index+1) < pages?size>,</#if>
should have been:
<#if (page_index+1) < pages?size>,</#if>