Home » Java » java – How parse json file to MultiPolygon?-Exceptionshub

java – How parse json file to MultiPolygon?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I call an API to get geographical data. There is a MultiPolygon inside, unfortunatly I don’t success to parse it in my object MultiPolygon (Multipolygon is empty but the rest is well parsed).
I’m not sure about the good import of MultiPolygon but this is the only one I found without “error”.

Could you help me please ?

Api distant response:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "iris_ge.1",
            "geometry": {
                "type": "MultiPolygon",
                "coordinates": [
                    [
                        [
                            [
                                660450.4,
                                6835323.8
                            ],
                            [
                                660411.3,
                                6835302.4
                            ],
...

Java code:

import org.elasticsearch.common.geo.builders.MultiPolygonBuilder;

@Data
@NoArgsConstructor
@JsonIgnoreProperties
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FeatureIris {

    private MultiPolygonBuilder geometry;

    private Properties properties;
}

Test parsing:

enter image description here

How to&Answers: