出现问题:
terminate called after throwing an instance of 'Json::LogicError'
what(): Value is not convertible to Int.
Aborted
解决方案
Json::Value dish;
dish["name"] = "黄焖鸡";
dish["price"] = "1300";
问题就出在第三行的dish[“price”]="1300"这里,price这个字段在数据库中设置的类型是int型,而这里将一个字符串类型赋给了它,导致了问题的发生。只需要将这一句改成dish["price"] = 1300;
就解决问题了,根本问题就是不同类型之间不能直接赋值。