question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stubbing application/json response without having to escape double quotes in response body

See original GitHub issue

How can I stub application/json response without having to escape all the double quotes, i.e.: I want to get rid off all of those escape chars in response.body contents:

{
    "request": {
            "method": "GET",
            "url": "/some/thing"
    },
    "response": {
            "status": 200,
            "body": "{\"id\": \"1\", \"type\": \"something\"}",
            "headers": {
                    "Content-Type": "application/json"
            }
    }
}

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6

github_iconTop GitHub Comments

24reactions
piotrpolakcommented, Mar 21, 2019

You can always use jsonBody instead of body and have much cleaner code:

{
    "request": {
            "method": "GET",
            "url": "/some/thing"
    },
    "response": {
            "status": 200,
            "jsonBody": {"id": "1", "type": "something"},
            "headers": {
                    "Content-Type": "application/json"
            }
    }
}
4reactions
stefanoj3commented, Mar 6, 2018

For the next person needing this: at least on wiremock 2.8 the property is actually called bodyFileName, not bodyFilePath.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stubbing application/json response without having to escape ...
How can I stub application/json response without having to escape all the double quotes, i.e.: I want to get rid off all of...
Read more >
How to escape double quotes in JSON - Stack Overflow
This solution helps in a Swift version building a string that's added to arguments for a JSON POST.
Read more >
"Unexpected character ', while reading `payload` as Json ...
In JSON, you don't need to escape single quotes inside a value that is enclosed with double-quotes. In the case that you have...
Read more >
JSONObject - Android Developers
When the requested type is a double, other Number types will be coerced using ... Creates a new JSONObject with name/value mappings from...
Read more >
Groovy Language Documentation
If your code is indented, for example in the body of the method of a class, ... And you can escape the escape...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found