Marcin Z.
12/13/2023, 8:31 AM"tracking": "{{jsonPath request.body '$.tracking'}}"
(without extra quotation in jsonBody
) where "tracking" is an array ?
My mapping:
{
"request": {
"method": "PUT",
"urlPathPattern": "/orders/[0-9]+",
"bodyPatterns": [
{
"matchesJsonPath": "$.tracking[*]"
}
]
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"jsonBody": {
"id": "{{request.pathSegments.[4]}}",
"type": "external",
"tracking": "{{jsonPath request.body '$.tracking'}}"
},
"transformers": [
"response-template"
]
}
}
but I've got (after upgrade) JsonMappingException :
... com.fasterxml.jackson.databind.JsonMappingException: {
"errors" : [ {
"code" : 10,
"source" : { },
"title" : "Error parsing JSON",
"detail" : "Unexpected character ('1' (code 49)): was expecting comma to separate Object entries\n at [Source: (String)\"{\"id\":\"11111\",\"type\":\"external\",\"tracking\":\"[\"123\",\"345\"]\"}\"; line: 1, column: 48]"
} ]
It looks that for:
{
"type": "REQUEST",
"method": "PUT",
"path": "<http://localhost:8099/orders/11111>",
"headers": [],
"body": {
"status": "readyforshipment",
"tracking": [
"123",
"345"
]
}
}
the generated response was:
{"id":"11111","type":"external","tracking":"["123","345"]"}
where "["123","345"]"
is invalid.
How can I use request reference to an array in jsonBody
to skip surrounding quation marks?
Btw, my response is much bigger. I would prefer not to abandon jsonBody
in favour of body
.
It worked wine with 3.0.0-beta-10.Marcin Z.
12/14/2023, 11:52 AM"tracking": "{{{array 123 456}}}",
which generates "tracking":"[123, 456]"
which is not illegal, but incorrect. Just "tracking":[123, 456]
is expected.Gunjan Basak
12/19/2023, 8:40 PM{
"id": "{{request.pathSegments.[4]}}",
"type": "external",
"tracking": {{jsonPath request.body '$.tracking'}}
}
Marcin Z.
12/21/2023, 10:54 AMCaused by: java.lang.ExceptionInInitializerError: Exception com.github.tomakehurst.wiremock.standalone.MappingFileException: Error loading file /.../src/test/resources/mappings/updateOrderTracking.json:
Unexpected character ('{' (code 123)): was expecting double-quote to start field name
Marcin Z.
12/21/2023, 10:55 AMMarcin Z.
12/21/2023, 11:01 AM"tracking":"[123, 456]"
is also generated. However, the error is not generated, maybe parsing with the JSON decoder was added after that (and we were asserting that particular in our tests).Marcin Z.
12/21/2023, 11:02 AMjsonBody
?