title: Save json in userDefaults
body: <p>This is the set function</p>
  
  <pre><code>func setSelectedDivisions(_ division:[Division]) {
  
      if (division.count != 0) {
          self.userDefaults.set(division.toJSONString(), forKey: "selectedDivisions")
          self.userDefaults.synchronize()
      }
      else{
          self.userDefaults.removeObject(forKey: "selectedDivisions")
          self.userDefaults.synchronize()
      }
  }
  </code></pre>
  
  <p>and this is the get function</p>
  
  <pre><code>func getSelectedDivisions() -&gt; [Division] {
  
      if let json = self.userDefaults.value(forKey: "selectedDivisions"){
          print(json)
      }
  
      if let json = self.userDefaults.value(forKey: "selectedDivisions") as? Array&lt;Dictionary&lt;String, Any&gt;&gt;  {
          if  json.count != 0{
              let  divisions = Mapper&lt;Division&gt;().mapArray(JSONArray: json)
              if divisions.count != 0{
                  return divisions
              }
          }
      }
      return []
  }
  </code></pre>
  
  <p>in get function i got error told me that my serialization is wrong.
  this is the json i trying to get it </p>
  
  <blockquote>
    <p>[{"name":"أ","img":"http://www.smsalmaali.com/images/cclass/21.jpg","name2":"الصف الاول","id1":"21","id2":"1"}]</p>
  </blockquote>
  
  <p>any idea to fix it ?</p>