Click here to Skip to main content
15,885,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the below code .

i want to store that url (It is JSON Data) as an array. please help me

What I have tried:

let ur = URL(string:"http://demo.cogzidel.com/dropinn416/mobile/search/discover?common_currency=INR&start=1")






let task = URLSession.shared.dataTask(with: ur!) { (data, response, error) in
    if error != nil
    {
        print("Error")
    }
    else
    {
        if let contant=data
        {
            do
            {
                let dictArray = try JSONSerialization.jsonObject(with: contant, options: JSONSerialization.ReadingOptions.mutableContainers) as? [Dictionary<String, AnyObject> ]
Posted
Updated 19-Apr-17 7:30am
Comments
Richard MacCutchan 19-Apr-17 12:07pm    
Then create an array and fill it with the data. What is the problem?

1 solution

In JavaScript we can use  JSON.stringify to convert an java script array into a JSON formatted string

Check this if it can help you.

Convert JavaScript Array to JSON - ProjectsGeek[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900