Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:11:38+00:00 2026-06-13T13:11:38+00:00

I have a string with escape characters in such a way that the when

  • 0

I have a string with escape characters in such a way that the when the string is printed it results in another string with valid escape characters. How do i retrieve that string which looks like the one when the first string is printed?

Here’s the code – the initial string looks as such:

String string = "{\"agent\":\"{\\\"name\\\":\\\"James Bond\\\"}\"}";
System.out.println("str: "+string);

Executing the code would produce

str: {"agent":"{\"name\":\"James Bond\"}"}

I was to get the string as it appears in the output.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:11:39+00:00Added an answer on June 13, 2026 at 1:11 pm

    You can use the String unescapeJava(String) method of StringEscapeUtils from Apache Commons Lang.

    example:

    String in = "a\\tb\\n\\\"c\\\"";
    
    System.out.println(in);
    //This prints
    // a\tb\n\"c\"
    
    String out = StringEscapeUtils.unescapeJava(in);
    
    System.out.println(out);
    //This prints
    // a    b
    // "c"
    

    You can see more on How to unescape a Java string literal in Java?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that looks like this: public static String escape(String text) {
Say I have a string that looks like this: str = The &yquick &cbrown
I have a query that returns a string, as well as an escape character
I have a string that contains ampersands. I need to escape each ampersand in
I have a bunch of string with special escape codes that I want to
I have string that look like Array that fetched from other webservice like this
I have a string that contains unicode escape codes, eg. @D\u017cem (\u017c is code
I have data templates that looks like: <DataTemplate> <TextBlock DataContext={Binding Fields[ABC]} Text={Binding}/> </DataTemplate> <DataTemplate>
When you have non-fixed width characters (such as \t ) in a string ,
I have a string with special characters like this: äöüß& Now I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.