unipart body is wrapped with outer string quotes.
See original GitHub issueDescribe the bug When the request body is a json string, then when getting request body, it is wrapped around additional string quotes.
To Reproduce Steps to reproduce the behavior:
- Create the request object
RequestBodyEntity request = Unirest.post("/post")
.basicAuth("foo", "bar")
.header("Content-Type", "application/json")
.queryString("foo", "bar")
.body("{\"body\": \"sample\"}");
Expected behavior
request.getBody().get().uniPart().getValue().toString()
should return "{\"body\": \"sample\"}"
but returns ""{\"body\": \"sample\"}""
instead.
Screenshots
If applicable, add screenshots to help explain your problem.
Environmental Data:
- Java Version - 11
- Version [e.g. 3.8.06]
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Strings sent through Web API's gets wrapped in quotes
I am receiving a JSON string that has been wrapped in quotes, once for each API. The string may start out like this:...
Read more >Remove Beginning and Ending Double Quotes from a String
In this tutorial, we'll study different approaches for removing beginning and ending double quotes from a String in Java.
Read more >about Quoting Rules - PowerShell | Microsoft Learn
Describes rules for using single and double quotation marks in PowerShell.
Read more >How to Quote a String in Python - codingem.com
A string is wrapped around a set of single quotes or double quotes. ... Use single quotes in the outer string and double...
Read more >Quoting in HTML: Quotations, Citations, and Blockquotes
It's all too common to see the incorrect HTML used for quotes in markup. ... If you need something more decorative that falls...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well, “fixing” isn’t the right term, you are asking a JSON object mapper to turn a string into a JSON string, and it is doing that. So if we change that, then that is a change in behavior. It might still be the right thing to do, because I’m willing to bet more people use the method by mistake than actually want a string to be a json string. But it’s still a breaking change (just a small one)
I’ll most likely make the change.
Thanks for the quick response on this.