0

I am trying to get Images embedded between text in JSON response. I am using Retrofit2 and RxJava2 for fetching data from the server.

Below is my JSON response:

{
    "ID": "22259",
    "post_author": "22",
    "post_date": "2020-03-03 10:44:21",
    "post_date_gmt": "2020-03-03 05:14:21",
    "post_content": "<h2><span style=\"font-size: 18pt; font-family: Georgia, Palatino;\"><strong>Egg 
Vegetarian or Non Vegetarian</strong></span></h2>\n<p><span style=\"font-size: 14pt; font-family: 
Georgia, Palatino;\">Our society comprises of vegetarians, non-vegetarians and then eggetarians. But 
it is surprising to know the word eggetarian? Because, since ages, we are not able to put the eggs 
into veg category or the non-veg category.  Few people consider that eggs are non-vegetarian since 
they come from a hen i.e. a living being. On the other hand, some people believe that they are 
vegetarian. So, let us know in depth about these eggs.</span></p>\n<p><span style=\"font-size: 14pt; 
font-family: Georgia, Palatino;\">Finally, now scientists have given us the answer for this 
controversy. After studying in depth about this and doing their research, scientists have put end to 
this debate &amp; said that eggs are '<strong><a href=\"https://www.flypped.com/best-diet-to- 
increase-long-life-expectancy/food/\">VEGETARIAN</a></strong>'.</span></p>\n<p><span style=\"font- 
size: 14pt; font-family: Georgia, Palatino;\">This is excellent news for vegetarians as now; they can 
add one more thing to their diet.</span></p>\n<p><span style=\"font-size: 18pt; font-family: Georgia, 
Palatino;\"><strong>Vegetarian Eggs 1 Composition of Egg</strong></span></p>\n<p><img 
class=\"aligncenter size-full wp-image-22261\" src=\"https://www.flypped.com/wp- 
content/uploads/2020/03/Composition-of-Egg.jpg\" alt=\"Composition of Egg\" width=\"800\" 
height=\"300\" /></p>\n<p><span style=\"font-size: 14pt; font-family: Georgia, Palatino;\">Scientists 
explained that the egg consist of 3 parts i.e. egg shell, egg white and egg yolk. The yolk consists 
of fat, cholesterol and proteins while whites have only protein.</span></p>\n<p><span style=\"font- 
size: 14pt; font-family: Georgia, Palatino;\">Scientists also said that the eggs that which are 
consumed by us daily aren't fully developed and don't have embryos. For this one is not eating 
bird/animal as these eggs don't have embryos and are unfertilized.</span></p>\n<p><span style=\"font- 
size: 18pt; font-family: Georgia, Palatino;\"><strong>Vegetarian Eggs 2 Unfertilized eggs</strong> 
</span></p>\n<p><img class=\"aligncenter size-full wp-image-22262\" src=\"https://www.flypped.com/wp- 
,
    "post_title": "Are Eggs Vegetarian Or Non-Vegetarian? You Will Be Surprised To Know These Facts",
    "post_excerpt": "",
    "post_status": "publish",
    "comment_status": "open",
    "ping_status": "closed" 
}

How can I get Images and text from post_content key in JSON response?

halfer
  • 19,824
  • 17
  • 99
  • 186
Digvijay
  • 2,887
  • 3
  • 36
  • 86
  • 1
    try this https://stackoverflow.com/questions/2865452/is-it-possible-to-display-inline-images-from-html-in-an-android-textview – Amit pandey Mar 04 '20 at 12:57
  • use Gson for json parsing. check here https://futurestud.io/tutorials/retrofit-2-adding-customizing-the-gson-converter you will get post_content (String) - it is a field of your object MyResponse (check annotation @SerializedName). and inside String post_content you can obtain String.startWith("src") for example – Kirguduck Mar 04 '20 at 12:59
  • https://stackoverflow.com/questions/24114382/gson-how-to-get-serialized-name but Amit offered more correct way – Kirguduck Mar 04 '20 at 13:02

0 Answers0