Fixed json API (compatible with older php versions)