-
-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Labels
bugIssues describing a bug or pull requests fixing a bug.Issues describing a bug or pull requests fixing a bug.
Description
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

Schema objects
No response
Metadata
Metadata
Assignees
Labels
bugIssues describing a bug or pull requests fixing a bug.Issues describing a bug or pull requests fixing a bug.