This is the set function

```
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()
    }
}

```

and this is the get function

```
func getSelectedDivisions() -> [Division] {

    if let json = self.userDefaults.value(forKey: "selectedDivisions"){
        print(json)
    }

    if let json = self.userDefaults.value(forKey: "selectedDivisions") as? Array<Dictionary<String, Any>>  {
        if  json.count != 0{
            let  divisions = Mapper<Division>().mapArray(JSONArray: json)
            if divisions.count != 0{
                return divisions
            }
        }
    }
    return []
}

```

in get function i got error told me that my serialization is wrong.
this is the json i trying to get it 

> 
> [{"name":"أ","img":"http://www.smsalmaali.com/images/cclass/21.jpg","name2":"الصف الاول","id1":"21","id2":"1"}]
> 
> 
> 

any idea to fix it ?