Skip to content

If a json property starts with a capital letter, it is not included in the deserialized object #546

Open
@dermotblairca

Description

@dermotblairca

Describe the bug

For example, if the price on the offer is "Price", it will not be picked up.

Steps to reproduce

This unit test reproduces the issue:

[Test]
public void GetSchemaOrgOffers_GetOfferInProduct_GetPrice()
{
    // Arrange
    var pageContent = File.ReadAllText("C:/SchemaOrgTestPages/SchemaNetProductExample.json");

    // Act
    var product = SchemaSerializer.DeserializeObject<Product>(pageContent);

    // Assert
    Assert.IsTrue(product.Offers.Value2.Any(o => o.Price.HasValue1 || o.Price.HasValue2));
}

The contents of the SchemaNetProductExample file is:

{
	"@context": "http://schema.org/",
	"@type": "Product",
	"name": "Cucumber Mint Lip Balm",
	"title": "Cucumber Mint Lip Balm",
	"image": "https://www.burtsbees.com/dw/image/v2/AAPA_PRD/on/demandware.static/-/Sites-burtsbees-master-catalog/default/dw19603097/images/large/NI-44070_BBd_LIP_CB_4Pk_CucumberMint_Frnt_13-07-18-1300.jpg?sw=380&sh=380&sm=fit",
	"description": "",
	"brand": "Burt's Bees",
	"sku": "792850905337",
	"gtin": "792850900936",
	"size": "4 Pack",
	"color": "",
	"offers": {
		"@type": "Offer",
		"url": "https://www.burtsbees.com/product/cucumber-mint-lip-balm/VM-792850900936.html",
		"priceCurrency": "USD",
		"Price": "11.99",
		"availability": "http://schema.org/OutOfStock",
		"itemCondition": "http://schema.org/NewCondition"
	}
}

It works fine when the price is lower case and Assert.IsTrue passes. However when price starts with a captial P, the Assert.IsTrue fails as both HasValue1 and HasValue2 are false on the offer.

Expected behaviour

I think it should pick up the price irrelevant of the case, as the following website says it is valid schema.org: https://validator.schema.org/

Schema objects

https://schema.org/Offer

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssues describing a bug or pull requests fixing a bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions