-
-
Notifications
You must be signed in to change notification settings - Fork 86
Regression in deserializing @language inside @context (from #63) #329
Copy link
Copy link
Closed
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
In #63, the library added support for deserializing @context objects. But it appears that OP's original example doesn't deserialize any more. I've seen schema.org data in the wild that uses this format.
@RehanSaeed your comment #63 (comment) mentioned the test case below but it wasn't included in the PR so did not trigger any failures. This test case does not pass any longer
private const string JsonWithLanguageInContext =
"{\r\n" +
"\"@context\": [ \"http://schema.org\", { \"@language\": \"it\" } ],\r\n" +
"\"@type\": \"LocalBusiness\",\r\n" +
"\"@id\": \"https://example.com/mario-rossi-srl\",\r\n" +
"\"name\": \"Mario Rossi\"\r\n" +
"}";
[Fact]
public void DeserializeObject_WithLanguageInContext_DeserializesSuccessfully()
{
var localBusiness = JsonConvert.DeserializeObject<LocalBusiness>(JsonWithLanguageInContext);
// Asserts....
}The cause appears to be that this line of code tries to deserialize the array as an object, which fails. It could be fixed by adding a separate else-if for arrays.
Steps to reproduce
- Run the test case included above
Expected behaviour
- Model deserializes correctly.
Schema objects
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssues describing a bug or pull requests fixing a bug.Issues describing a bug or pull requests fixing a bug.