While retrieving information in GET, I get proper response. Now, I am trying to send some data back to Server using Post call. But when I do it, I get classCastException
Here is model class
public class Polygon implements Parcelable
{
@SerializedName("type")
@Expose
private String type;
@SerializedName("coordinates")
@Expose
private List<List<List<Double>>> coordinates = new ArrayList<>();
public final static Creator<Polygon> CREATOR = new Creator<Polygon>() {
@SuppressWarnings({
"unchecked"
})
public Polygon createFromParcel(android.os.Parcel in) {
return new Polygon(in);
}
public Polygon[] newArray(int size) {
return (new Polygon[size]);
}
};
protected Polygon(android.os.Parcel in) {
this.type = ((String) in.readValue((String.class.getClassLoader())));
in.readList(this.coordinates, (List.class.getClassLoader()));
}
public Polygon() {
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<List<List<Double>>> getCoordinates() {
return coordinates;
}
public void setCoordinates(List<List<List<Double>>> coordinates) {
this.coordinates = coordinates;
}
public void writeToParcel(android.os.Parcel dest, int flags) {
dest.writeValue(type);
dest.writeList(coordinates);
}
public int describeContents() {
return 0;
}
}
Here is the json I am trying to retrieve and send it back later.
{"polygon": {
"type": "Polygon",
"coordinates": [
[
[
-105.18367,
39.54363
],
[
-105.18367,
39.98435
],
[
-104.33773,
39.98435
],
[
-104.33773,
39.54363
],
[
-105.18367,
39.54363
]
]
]
}
}
For this I get java.lang.ClassCastException: java.lang.Double cannot be cast to java.util.Collection
.
I tried converting it to separate class to use it as CREATOR
but then GET call fails.
Any help would be great!