Skip to content
Advertisement

How to detect new lines from a Json text in Java, Android

The text is received from a Json is like this:

This is sentence 1.

This is <b>sentence 2</b>.

I don’t know how to detect that empty space in java/Android.

I want to replace the new lines from the Json with <br/> because I’m trying to find a workaround to this problem: Android, format text from Json to HTML removes new lines and white spaces

Advertisement

Answer

It seems that the Json text had rn inside that I did not see, and I just had to use:

jsonText.replace("rn", "<br/>");

The json is extracted from a MySql database. I could see rn special characters only when I did a sql export from PHPmyAdmin.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement