fix comment count and generate JSON