Decision management API returns invalid JSON response when evaluating complex rules

Our loan approval decision API is returning malformed JSON when evaluating rules with nested conditions. Simple rules work fine, but complex multi-level conditions break the response structure.

Example broken response:


{
  "decision": "approved",
  "conditions": [
    {"creditScore": 750, "result": true},
    {"income": 85000, "result": true,}
  ]
}

Notice the trailing comma after the second result. Running it through a JSON linter confirms it’s invalid. The rule output seems to have serialization issues with nested condition handling. Anyone experienced this with the decision management module on Appian 22.3?

Check the decision management API endpoint configuration. There’s a setting for response format that can be set to ‘strict’ or ‘lenient’. In lenient mode, it sometimes allows trailing commas which creates invalid JSON. Also verify that your rule version is the latest - older cached versions might have bugs that were fixed.

This looks like a serialization bug in how the decision engine outputs nested arrays. Check if you’re using custom rule output formatting or the default JSON serializer. Also, are you applying any post-processing to the response before returning it? Sometimes custom transformation logic introduces these syntax errors.

We’re using the default JSON serializer from the decision management module. No custom post-processing on our end. The weird thing is it only happens when there are more than 3 nested conditions. With 1-3 conditions, the JSON is perfectly valid. Could this be a known issue in 22.3?

I can provide a comprehensive solution that addresses all three problem areas you’re encountering:

Rule Output Serialization: The core issue is how nested decision outputs are being serialized. Instead of manually constructing JSON, use Appian’s built-in serialization:


a!toJson(
  a!map(
    decision: local!result,
    conditions: local!conditionsList
  )
)

This ensures proper JSON formatting regardless of nesting depth. Never concatenate JSON strings manually - it’s the primary cause of trailing commas and malformed structures.

Nested Condition Handling: For complex multi-level conditions, structure your rule logic to build clean arrays:


local!conditionsList: a!forEach(
  items: local!evaluatedConditions,
  expression: if(
    isnull(fv!item.result),
    null,
    a!map(condition: fv!item.name, result: fv!item.result)
  )
)

The key is filtering out null results BEFORE serialization. Use reject(isnull(), local!conditionsList) to remove null entries that cause serialization issues.

JSON Response Validation: Implement validation at the API endpoint level:

  1. Add a validation layer using a!isValidJson() before returning responses
  2. Enable strict JSON mode in your API settings (Admin Console > Integrations > API Response Format)
  3. Add error handling that catches serialization failures:

if(
  a!isValidJson(local!response),
  local!response,
  a!httpResponse(
    statusCode: 500,
    body: "Serialization error in decision output"
  )
)

Additional Fixes:

  • Update to Appian 22.4 or 23.1 - there were serialization improvements in the decision engine
  • Review your decision table for any expression rules that return Text instead of proper data types
  • Check for any custom plugins that might be interfering with JSON serialization
  • Clear the decision rule cache after making changes (Admin Console > Caching)

For loan approval specifically, consider implementing a response schema validator that catches these issues before they reach production. The decision management module should always output valid JSON when using native Appian functions rather than manual string construction.

Thanks for all the suggestions. I’m going to review our rule structure and add proper null handling.