Umbraco.Commerce.Issues
Umbraco.Commerce.Issues copied to clipboard
Adding square brackets in a shipping provider settings throws a JSON exception (Unexpected character encountered while parsing value)
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:
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:
- 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).
- Add the shipping method and make it available for you shipping country
- In the back office, enter square brackets '[]' into the shipping setting field
- Try and go through a checkout and it fails when calculating shipping rates.
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