Skip to content

Exception when deserializing a feature with nested object in properties (I think) #116

Description

@HarelM

I've created the following test for geojson4stj (I wanted to migrate from newtonsoft to STJ):

        [TestMethod]
        public void DeserializationFailure()
        {
            string str = @"
                 {
            ""type"" : ""Feature"",
            ""bbox"" : [
            35.0666687,
            32.5499986,
            35.0666687,
            32.5499986
                ],
            ""geometry"" : {
                ""type"" : ""Point"",
                ""coordinates"" : [
                35.0666687,
                32.5499986
                    ]
            },
            ""properties"" : {
                ""accuracy"" : ""minutes"",
                ""description"" : ""מעיין בסמוך לעץ אשל גדול \n"",
                ""description:he"" : ""מעיין בסמוך לעץ אשל גדול \n"",
                ""gns_ref"" : ""-780914"",
                ""name"" : ""עין ניצה"",
                ""name:en"" : ""Ein Nizza"",
                ""name:he"" : ""עין ניצה"",
                ""natural"" : ""spring"",
                ""source"" : ""GEOnet Names Server (gns)"",
                ""identifier"" : ""node_278470424"",
                ""poiLastModified"" : ""2021-10-08T18:06:37.0000000"",
                ""poiVersion"" : 5,
                ""poiSearchFactor"" : 1.0,
                ""poiIcon"" : ""icon-tint"",
                ""poiIconColor"" : ""blue"",
                ""poiCategory"" : ""Water"",
                ""poiSource"" : ""OSM"",
                ""poiLanguage"" : ""all"",
                ""poiContainer"" : false,
                ""poiNames"" : {
                    ""he"" : [
                    ""עין ניצה""
                        ],
                    ""en"" : [
                    ""Ein Nizza""
                        ],
                    ""all"" : [
                    ""עין ניצה""
                        ]
                },
                ""poiId"" : ""OSM_node_278470424"",
                ""poiGeolocation"" : {
                    ""lat"" : 32.5499986,
                    ""lon"" : 35.0666687
                },
                ""poiAlt"" : 172.0123568908041
            }
        }
                 ";
            var factory = new GeoJsonConverterFactory();
            var indentedOptions = new JsonSerializerOptions
            {
                DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
                WriteIndented = true
            };
            indentedOptions.Converters.Add(factory);

                 var f = JsonSerializer.Deserialize<Feature>(str, indentedOptions);
                 Assert.IsNotNull(f);
        }

This test is failing with an exception about unableing to convert from IFeature to Feature or something similar.
I think this was also a problem with the previous non STJ implementation, but I can't find the relevant issue :-(

I think the problem is with the nested object inside the properties, I haven't tried to narrow down the geojson feature.
Let me know if there's anything I can do to help out.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions