I’m using WireMock’s standalone version with Handlebars for creating dynamic responses. I need to include a static JSON array in the JWT payload. However, when I try to define the array in the mapping file, it’s treated as a string rather than a JSON array.
Here is a simple example of my configuration:
Request:
{
"request": {
"method": "GET",
"urlPath": "/api/test"
},
"response": {
"status": 200,
"body": "{{{jwt
userId='12345'
userName='testUser'
myArray='[{"key1":"value1"}, {"key2":"value2"}]'
isActive=true
role='admin'
}}}"
}
}
Expected Output:
{
"userId": "12345",
"userName": "testUser",
"myArray": [
{"key1": "value1"},
{"key2": "value2"}
],
"isActive": true,
"role": "admin"
}
The array myArray
is being treated as a string, not as a JSON object array. How can I define and handle a static JSON array correctly in WireMock Handlebars to be recognized as a JSON array, not a string?