I have a class that I want to fill then pass to an event rule as payload. like this.
public class Payload
{
public string Site {get;set;}
public string Region {get;set}
....
}
now in my CDK I fill these with other values
var payload = new PayLoad()
payload.Site = "NY";
payload.Region = "1"
....
var _json = JsonSerializer.Serialize(payload )
Now, I want to pass this the RuleTargetInput for the event rule
eventRule.AddTarget(new LambdaFunction(fn, new LambdaFunctionProps
{
Event = RuleTargetInput.FromObject(_json )
}));
And the event shows something like this
"{"\Site\":\"NYC\",\"Region\"}"....
The lambda function does not like this payload. if I manually remove the backslashes then it works. is there a way with System.Text.Json to remove the backslashes on Serialize?