No serializer found for class org.json.JSONObject and no properties discovered to create BeanSeriali

问题:定义JSONObject对象,启动程序报错

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

原因是import org.json.JSONObject;没有实现序列化接口。
解决方法:改用

import net.minidev.json.JSONObject;

你可能感兴趣的:(json,java,开发语言,JSONObject)