I have a JSON File that looks something like this. I want to be able to skip the discounts property if it is empty.
[
{
"state": "CT",
"postalCode": "06010",
"species": "Cat",
"unit": "years",
"value": 0,
"gender": "Male",
"breed": "Feral",
"discounts": "",
"reimbursement": 70,
"deductible": 250,
"annualLimit": 5000
},
{
"state": "CT",
"postalCode": "06010",
"species": "Cat",
"unit": "years",
"value": 0,
"gender": "Male",
"breed": "Feral",
"discounts": "military",
"reimbursement": 70,
"deductible": 250,
"annualLimit": 5000
}
]
In the file, it shows it as an empty string but the payload doesn’t accept that as a valid enum value.
Payload:
{
"productCode": [
"safecoPet"
],
"primaryResidence": {
"state": "{{state}}",
"postalCode": "{{postalCode}}"
},
"pets": [
{
"name": "Charlie",
"species": "{{species}}",
"breed": "{{breed}}",
"age": {
"unit": "{{unit}}",
"value": {{value}}
},
"gender": "{{gender}}",
"birthDate": "2018-09-03",
"altered": true
}
],
"productOptions": {
"reimbursement": {{reimbursement}},
"deductible": {{deductible}},
"annualLimit": {{annualLimit}},
"coverageTypesSelected": [
"Wellness"
],
"discountSelected": [
"{{discounts}}"
]
}
}
Error response:
{
"code": 400,
"message": "Bad request",
"description": [
"/productOptions/discountSelected/0 is not a valid enum value"
}
Any help is much appreciated!