Logic App equals函数返回True而非true致JSON解析失败,求原因
equals() function output uppercase True/False instead of JSON-compliant lowercase true/false? Problem Context
When using the equals() expression in a Logic Apps JSON payload:
"apiTicket": @{equals(body('Get_Ticket_Details')?['takenby'], 'Integration Agent')}
The runtime outputs:
"apiTicket": True
This causes a deserialization error in downstream HTTP POST requests:
{
"error": {
"code": "InvalidRequestContent",
"message": "The request content is not valid and could not be deserialized: 'Unexpected character encountered while parsing value: T. Path 'params.apiTicket', line 15, position 17.'."
}
}
Per Microsoft's documentation, equals() should return lowercase true/false—here’s why this discrepancy happens:
String embedding triggers .NET-style serialization
When you use the@{...}syntax to embed an expression directly into a JSON template string, the Logic Apps runtime treats the expression’s return value as a .NET type, then calls its nativeToString()method for string substitution. .NET’sbooltype outputs uppercaseTrue/Falseby default, which doesn’t match JSON’s lowercase boolean requirement.Context-dependent serialization behavior
Theequals()function itself does return a proper boolean value. If you use it directly in an action like "Compose" (not embedded in a string template), the runtime correctly serializes it to JSON’s lowercasetrue/false. The issue only arises when embedding the expression result into a pre-defined JSON string, where the runtime prioritizes .NET string formatting over JSON type compliance.Underlying .NET framework dependency
Logic Apps’ workflow language is built on .NET. In string substitution scenarios, the runtime doesn’t automatically convert .NET boolean types to JSON-compatible lowercase strings. This is a specific edge case in how expression results are handled when injected into string templates, rather than a bug in theequals()function itself.
内容的提问来源于stack exchange,提问作者ww-sam

