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

  • Home
  • SEARCH
  • 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 1062301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:36:19+00:00 2026-05-16T18:36:19+00:00

I am using the official JSON library for my java project ad i have

  • 0

I am using the official JSON library for my java project ad i have noticed something weird.

If i have a json such as this:

{
  "text": "This is a multiline\n text"
}

And i try to get the string like this:

System.out.println(jsonObject.getString("text"));

I get this on the output:

This is a multiline\n text

Instead of :

This is a multiline
text

Anyone know of the correct way to handle the special characters such as \n and \t? I could always replace each one but I would have to handle all of them one by one.

  • 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-05-16T18:36:20+00:00Added an answer on May 16, 2026 at 6:36 pm

    Your above example is correct and displays correctly, however there’s “human readable” \n (which would be \n in a string) and there’s escaped character \n (which would be the raw \n in a string). I’m guessing whatever library you are using is generating the human readable code rather than the proper escape code.

    Try: json_obj.text.replace(/\\n/g,"\n"); to convert the string back.

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

Sidebar

Related Questions

I am uploading video on twitvid using its official php library. http://www.martin-gardner.co.uk/twitvid/twitvid.class.example.php#embedvideo But when
I'm using the official FBConnect library for iOS and trying to get it working
I have integrated the Facebook SDK in my app using the official facebook connect
I've got a CodeIgniter project using the Facebook Connect official PHP implementation. For the
I'm using official mongodb driver for c# in my test project and i've already
I am using the official 10gen C# driver for mongoDB. I have some code
I tried this using Jsonkit and Apple's JSON serializer with no luck. It keeps
I am using the official Dropbox API for Java. So far, everything works smoothly.
If i using the official jquery lib the validator (bassistance.de/query-plugins/jquery-plugin-validation) have an annoying bug,
Does anyone have a code example that follows best practices of using MongoDB Official

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.