encode each product into json