I want to parse the json string and displays in the UITextView. I am getting the data with HTML string with key and values. This is the below sample string response from the server,
{"":"<strong>Adidas<\/strong><br>Enjoy 10% off","Period":"10 Oct 2019 - 11 Nov 2019","Description":"<p>Enjoy 30% off
"Terms & Conditons":"<ol>\n<li>It's available only in peak hours<\/li>\n}
I need to display like the below format with HTML,
Expected output:
Adidas
Enjoy 10% off
Period:
10 Oct 2019 - 11 Nov 2019
Description:
Enjoy 30% off.
Terms & Conditons:
It's available only in peak hours
I've used dictionary and extracted the data but the problem is order of the data is not in sequence.
func setupData(responseString : String)
{
// Convert string to dictionary for extracting the keys and values
// Need to maintain the order while adding the data
let content = convertToDictionary(text: responseString)
var text : String = ""
if let contentDataDict = content
{
for (key, value) in contentDataDict
{
// want to append the key and values in the sequence order
textView.attributedText = text.htmlToAttributedString
}
}
}
How can I parse and display the data as per the expected output.