Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully qualified property names not recognized in deserialization #692

Open
Buthrakaur opened this issue Dec 5, 2024 · 0 comments
Open
Labels
bug Issues describing a bug or pull requests fixing a bug.

Comments

@Buthrakaur
Copy link

Buthrakaur commented Dec 5, 2024

Describe the bug

Property names can be fully qualified (prefixed with namespace) in Schema.org JSON the deserialization doesn't seem to work for that. I'm trying to use this library for Schema.org based API integration.

Steps to reproduce

Copy of part of data from the test https://github.com/RehanSaeed/Schema.NET/blob/main/Tests/Schema.NET.Test/Examples/RestaurantTest.cs#L63 with fully qualified property names in a test which fails:

        var json =
        """
        {
            "@context": "https://schema.org",
            "@type": "Restaurant",
            "@id": "https://davessteakhouse.example.com",
            "name": "Dave's Steak House",
            "https://schema.org/address": {
                "@type": "PostalAddress",
                "addressCountry": "US",
                "addressLocality": "New York",
                "addressRegion": "NY",
                "postalCode": "10019",
                "https://schema.org/streetAddress": "148 W 51st St"
            }
        }
        """;
        var restaurant = SchemaSerializer.DeserializeObject<Restaurant>(json)!;

        // following throws as restaurant.Address is not populated
        restaurant.Address.HasValue.ShouldBeTrue();
        restaurant.Address.OfType<PostalAddress>().Single().StreetAddress.Single().ShouldBe("148 W 51st St");

Expected behaviour

Deserialization should populate even properties with fully qualified names - this is valid according to Schema.org definition
image

Schema objects

No response

@Buthrakaur Buthrakaur added the bug Issues describing a bug or pull requests fixing a bug. label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing a bug or pull requests fixing a bug.
Projects
None yet
Development

No branches or pull requests

1 participant