It’s sometimes handy (e.g, in test suites) to have a JSON string hardcoded. If you want to interpolate it to insert a variable, use $$””” and then {{ }}.
In this example my interpolation expression is the variable ratingUnitNumber:
var ratingUnitNumber = "test";
var cloudEvent = $$"""
{
"id": "5565db35-01a9-4596-b611-9b26d2210c6e",
"source": "https://s4h-dev.blah.govt.nz",
"type": "nz.govt.blah.s4.ratingunitchanged",
"subject": "blah",
"data": {
"ratingUnits": [
{
"ratingUnitNumber": "{{ratingUnitNumber}}"
}]
},
"time": "2024-03-11T23:09:27.5683052+00:00",
"specversion": "1.0"
}
""";
Hopefully that helps someone.
Your content is awesome. Thanks, your tutorials and whole blog is amazing.
exactly what i needed for my test, thank you!