Fix ID conversion for toJson and toArray