JSONObject和JSONArray 以及Mybatis傳入Map類型參數


  1. import org.json.JSONArray;
    import org.json.JSONObject;
  2. 將字符串轉化為JSONArray   JSONArray  jsonArray = new JSONArray(deviceInfo); //注意字符串的格式
  3. 將JSONArray轉化為JSONObject類型 JSONObject jsonObject = jsonArray.getJSONObject(0);
  4. 將值存入Map  Map<String,String> map = HashMap();    map.put("a",jsonObject.getString("a"));
  5. Mybatis傳入Map類型的參數
  6.     <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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM