-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Exception thrown The JSON value could not be converted to Schema.NET.IValues #389
Comments
I managed to get a minimal repro of the bug: [Fact]
public void Deserializing_ProductJsonLd_ReturnsProduct2()
{
var json = "{\"@context\":\"https://schema.org\",\"@type\":\"Review\",\"name\":null}";
var product = SchemaSerializer.DeserializeObject<Review>(json);
} Looks like the |
Thanks for the prompt reply @RehanSaeed |
Would you have an idea when this might be fixed @RehanSaeed? Thanks in advance. |
I put together this PR with some unit tests that repro this problem. The exception seems to be thrown deep in the bowels of |
Thanks again @RehanSaeed |
Describe the bug
The following exception is thrown when trying to parse the Product json in the following Walmart.com URL: https://www.walmart.com/ip/Air-Wick-Plug-in-Scented-Oil-Warmer-2-ct-White-color-Air-Freshener-Essential-Oils/14284640?athbdg=L1600
"System.Text.Json.JsonException: 'The JSON value could not be converted to Schema.NET.IValues. Path: $.name | LineNumber: 0 | BytePositionInLine: 29.'"
This validates fine on validtor.schema.org: https://validator.schema.org/#url=https%3A%2F%2Fwww.walmart.com%2Fip%2FAir-Wick-Plug-in-Scented-Oil-Warmer-2-ct-White-color-Air-Freshener-Essential-Oils%2F14284640%3Fathbdg%3DL1600
In my code, I am getting the Product json from the Script element and then calling the following:
var product = SchemaSerializer.DeserializeObject<Schema.NET.Product>(json);
I was also able to reproduce this by downloading the Schema.Net source and adding the following test to the ProductTest.cs file (as shown in Steps to reproduce):
Steps to reproduce
Add the following to ProductTest.cs file and run the test:
Expected behaviour
The JSON should be deserialized to an object of the Product class.
Schema objects
https://schema.org/Product
The formatted JSON of the Product in the Walmart.com URL is the following:
The text was updated successfully, but these errors were encountered: