- 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