I`m trying to convert List to Json String, here is my code
def getProductAsJson(txt:String):String={
var products=new ListBuffer[Product]()
val conn = DB.getConnection()
try {
val stmt = conn.createStatement
val q="SELECT * from m_products where pro_name like '"+txt+"%' "
println(q);
val rs = stmt.executeQuery(q)
while (rs.next()) {
products+=Product(Some(rs.getInt("idproduct")),rs.getString("pro_name"),rs.getBigDecimal("pro_retprice"),
rs.getString("pro_description"),rs.getString("pro_brand"),rs.getString("pro_type"),rs.getString("pro_sup"),rs.getString("pro_supref"),rs.getBigDecimal("pro_supprice"),rs.getBigDecimal("pro_markup"),Some(rs.getString("pro_imgpath")),rs.getInt("pro_active"));
}
} finally {
conn.close()
}
println(Json.toJson(products.toList).toString)
return Json.toJson(products.toList).toString
}
but i got this error
No Json serializer found for type List[models.Product]. Try to implement an implicit Writes or Format for this type.