UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How Can I Clean The API Response (JSON) From HTML Tags and Twitter Stuff

Forums > Swift

Hello guys, I'm trying to parse a JSON but in one of the responses it returns to me a string with a lot of HTML tags, twitter posts and more stuff inside like the one example down so my question is how can I clear all this html tags and stuff have the clean string so I can show it on the UI or is there a way that I can show that tweet same way on my app ?

This is how it returns to me

"<p dir=\"ltr\">Killers of the Flower Moon actor Leonardo DiCaprio probably didn't think attending the Super Bowl in Las Vegas would lead to him getting unknowingly roasted by SpongeBob SquarePants. But as ridiculous as that sounds, it's exactly what happened over the weekend.<\/p><p dir=\"ltr\">During the Nickelodeon broadcast for Super Bowl 58 on Sunday night, SpongeBob noted the number \"25\" in regard to the Oscar-winning actor. Then, the cartoon character laughs before saying, \"That was about his dating history,\" in a clip captured by <a href=\"https:\/\/twitter.com\/DiscussingFilm\/status\/1756876557325390104\" data-target=\"true\" target=\"_blank\" rel=\"noopener\">Discussing Film on X<\/a> (formerly known as Twitter) and seen below.<\/p><div data-embed-type=\"tweet\" data-src=\"https:\/\/twitter.com\/DiscussingFilm\/status\/1756876557325390104\" data-has-image=\"true\"><blockquote align=\"center\" class=\"twitter-tweet\" data-conversation=\"none\" data-mce-disable-toolbar=\"true\"><p dir=\"ltr\">SpongeBob makes a joke about Leonardo DiCaprio on the Nickelodeon <a href=\"https:\/\/twitter.com\/hashtag\/SuperBowl?src=hash&amp;ref_src=twsrc%5Etfw\">#SuperBowl<\/a> stream.<br \/>\u201cLeonardo DiCaprio, 25! That\u2019s his dating history.\u201d <a href=\"https:\/\/t.co\/e8YXhj1czK\" rel=\"nofollow \">pic.twitter.com\/e8YXhj1czK<\/a><\/p>  \u2014 DiscussingFilm (@DiscussingFilm) <a href=\"https:\/\/twitter.com\/DiscussingFilm\/status\/1756876557325390104?ref_src=twsrc%5Etfw\">February 12, 2024<\/a><\/blockquote>          <script type=\"text\/plain\" class=\"optanon-category-C0004\" async charset=\"utf-8\" data-service-name=\"twitter\" id=\"twitter-embed-1021795483\" src=\"\/\/platform.twitter.com\/widgets.js\"><\/script>    <\/div><p dir=\"ltr\">For those unaware, SpongeBob is bringing up DiCaprio's reputation for only dating women who are younger than 25 years old. In fact, <a href=\"https:\/\/www.dailymail.co.uk\/tvshowbiz\/article-11754715\/Leonardo-DiCaprio-wants-ditch-reputation-dating-women-25.html\" data-target=\"true\" target=\"_blank\" rel=\"noopener nofollow\">a Daily Mail story<\/a> from roughly a year ago reported that the actor was aware of the jokes made about his previous relationships.<\/p><p dir=\"ltr\">DiCaprio was recently seen on the big screen in Killers of the Flower Moon, which arrived on the streaming service Apple TV+ last month. Be sure to check out GameSpot's <a href=\"https:\/\/www.gamespot.com\/reviews\/killers-of-the-flower-moon-review-not-long-enough\/1900-6418138\/\" data-ref-id=\"1900-6418138\">Killers of the Flower Moon review<\/a>, plus a list of <a href=\"https:\/\/www.gamespot.com\/gallery\/the-10-most-punchable-leonardo-dicaprio-roles-including-killers-of-the-flower-moon\/2900-4912\/\" data-ref-id=\"2900-4912\">DiCaprio's top 10 most punchable roles<\/a>.<\/p><p dir=\"ltr\">Meanwhile, <a href=\"https:\/\/www.gamespot.com\/articles\/spongebob-squarepants-the-cosmic-shake-coming-to-ps5-and-xbox-series-x-s-in-october\/1100-6517611\/\" data-ref-id=\"1100-6517611\">SpongeBob SquarePants: The Cosmic Shake arrived on PS5 and Xbox Series X|S<\/a> in October. The video game originally launched on PC, PS4, Xbox One, and Switch in January 2023.<\/p><div data-embed-type=\"imageGallery\" data-ref-id=\"4912\"><div class=\"image-gallery__header\">The 10 Most Punchable Leonardo DiCaprio Roles, Including Killers Of The Flower Moon<\/div><div class=\"image-gallery__main\"><div class=\"image-gallery__item\"><img src=\"https:\/\/www.gamespot.com\/a\/uploads\/screen_medium\/1757\/17577455\/4209531-killersoftheflowermoon.jpg\" \/><\/div><div class=\"image-gallery__item\"><img src=\"https:\/\/www.gamespot.com\/a\/uploads\/screen_medium\/1757\/17577455\/4209524-romeoplusjuliet.jpg\" \/><\/div><div class=\"image-gallery__item\"><img src=\"https:\/\/www.gamespot.com\/a\/uploads\/screen_medium\/1757\/17577455\/4209525-catchmeifyoucan.jpg\" \/><\/div><div class=\"image-gallery__item\"><img src=\"https:\/\/www.gamespot.com\/a\/uploads\/screen_medium\/1757\/17577455\/4209526-revolutionaryroad.jpg\" \/><\/div><div class=\"image-gallery__item\"><img src=\"https:\/\/www.gamespot.com\/a\/uploads\/screen_petite\/1757\/17577455\/4209528-inception.jpg\" \/><\/div><div class=\"image-gallery__item\"><img src=\"https:\/\/www.gamespot.com\/a\/uploads\/screen_petite\/1757\/17577455\/4209527-jedgar.jpg\" \/><\/div><div class=\"image-gallery__item\"><img src=\"https:\/\/www.gamespot.com\/a\/uploads\/screen_petite\/1757\/17577455\/4209529-djangounchained.jpg\" \/><\/div><div class=\"image-gallery__item image-gallery__item--show-more\"><a class=\"js-click-tag\" data-click-tag=\"image gallery|see more\" href=\"\/gallery\/the-10-most-punchable-leonardo-dicaprio-roles-including-killers-of-the-flower-moon\/2900-4912\/\">See More<\/a><\/div><\/div><\/div>",
            "lede": "Let's just say 25 isn't a random number for the cartoon character to highlight for the Oscar-winning actor.",

This is what it actually looks like on the web page (sorry the pics just wont show in the page I don't know why so I put them like this.)

https://img.onl/zJltM0

https://img.onl/htqx3

1      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.