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.

unipart body is wrapped with outer string quotes.

See original GitHub issue

Describe 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:

  1. 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. image

Environmental Data:

  • Java Version - 11
  • Version [e.g. 3.8.06]

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rybercommented, Jul 28, 2020

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.

0reactions
haroon-sheikhcommented, Aug 2, 2020

Thanks for the quick response on this.

Read more comments on GitHub >

github_iconTop 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 >

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