- import org.json.JSONArray;
import org.json.JSONObject; - 将字符串转化为JSONArray JSONArray jsonArray = new JSONArray(deviceInfo); //注意字符串的格式
- 将JSONArray转化为JSONObject类型 JSONObject jsonObject = jsonArray.getJSONObject(0);
- 将值存入Map Map<String,String> map = HashMap(); map.put("a",jsonObject.getString("a"));
- Mybatis传入Map类型的参数
- <insert id="saveNewDeviceInfo" parameterType="java.util.Map">
insert into device (NAME,IP,MAC,Vendor,HardwareVersion,FirmwareVersion,Description) value ( #{NewName},#{NewIP},#{NewMac},#{Vendor},#{HardwareVersion},
#{FirmwareVersion},#{Description})
</insert>
转载于:https://www.cnblogs.com/fangpengchengbupter/p/7324872.html