Umbraco.Commerce.Issues icon indicating copy to clipboard operation
Umbraco.Commerce.Issues copied to clipboard

Adding square brackets in a shipping provider settings throws a JSON exception (Unexpected character encountered while parsing value)

Open justin-nevitech opened this issue 6 months ago • 3 comments

Describe the bug

I am creating a custom shipping provider and I need to store a JSON value which is an array of objects in the shipping provider setting. I can get this working from the front-end, but when calculating the shipping rates it throws and JSON error. The same error happens when just adding square brackets into a normal text field setting and not even using any JSON:

image

If you inherit from ShippingProviderBase without using a settings class it works but if you try and use a settings class you get the error. Obviously without inheriting from the settings class you won't get the settings in the UI.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a custom shipping provider with a simple text string setting in a settings class (as per https://docs.umbraco.com/umbraco-commerce/key-concepts/shipping-providers).
  2. Add the shipping method and make it available for you shipping country
  3. In the back office, enter square brackets '[]' into the shipping setting field
  4. Try and go through a checkout and it fails when calculating shipping rates.

image

Expected behavior

Shipping provider settings should be able to store and retrieve strings with square brackets (including JSON strings) without throwing an error.

Umbraco Commerce version:

13.1.6

justin-nevitech avatar Jul 30 '24 07:07 justin-nevitech