Developer forum

Forum » Development » Limiting JSON response with filled properties

Limiting JSON response with filled properties

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

According to the docs here: https://doc.dynamicweb.dev/documentation/headless/delivery-api/commerce.html sending a request with FilledProperties shoud limit the numer of fields being returned. I.e. a request like this:

/dwapi/ecommerce/products/10003?CurrencyCode=DKK&CountryCode=DK&FilledProperties=Id,Name,Price&PriceSettings.FilledProperties=priceWithVatFormatted,priceWithoutVatFormatted

should return just this:

{
  "id": "10003",
  "name": "Scattante CFR Elite ",
  "price": {
    "priceWithoutVatFormatted": "11.993,33 kr.",
    "priceWithVatFormatted": "14.991,67 kr.",
  }
}

However, what I see instead is that all fields are returned, with the non-filled properties having a value of null. I.e.: 

{
  "Id": "10003",
  "VariantId": null,
  "LanguageId": null,
  "Name": "Scattante CFR Elite ",
  "Title": null,
  "ShortDescription": null,
  "LongDescription": null,
  "MetaDescription": null,
  "MetaTitle": null,
  "MetaKeywords": null,
  "Number": null,
  "Created": null,

which defeats the purpose of controlling the fields a bit.

Did the null handling in System.Text.Json or Json.NET get lost somewhere?

Imar


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Imar

Yes, I think this is related to the default options of using System.Text.Json for serialization in default mode. I will see if we can re-configure this - created as devops#23953

BR Nicolai

 

You must be logged in to post in the forum