Hi, I am currently working on generating a respons...
# general
m
Hi, I am currently working on generating a response like the following template:
Copy code
"response": {
    "status": 200,
    "headers": {
      "Content-Type": "application/json"
    },
    "jsonBody": {
      "the_token": "some values",
      "token_type": "type 1",
      "generated_at": "{{now format='unix'}}",
      "expires_in": 3600
    },
    "transformers": ["response-template"]
  }
My issue is with the
generated_at
field: even though I am using
{{now format='unix'}}
, wiremock doesn't start and shows some java line error messages. I need it to be returned as an integer. Is there a way to achieve this directly within the
jsonBody
section? Please note that my actual response template is more complex than the example above, I simplified it here to highlight the issue. I came across this Stack Overflow discussion, which suggests using the
body
field instead of
jsonBody
, but that approach does not fit well with my use case. Is there a cleaner or simpler way to return
generated_at
as an integer in
jsonBody
? Thank you!
l
Unfortunately not. When you use jsonbody it will need to be valid json. Using templating without quotes makes it invalid json so this isnโ€™t an option I am afraid.
๐Ÿ‘ 1
m
Okay thank you @Lee Turner for the confirmation โœ…
๐Ÿ‘ 1