Tunds
Tunds

Reputation: 1817

Can't set type JSON for object in swift

Hi all i'm using Xcode 7 and swift2 but for some weird reason i'm unable to set an data object of type JSON, i've tried using different types and they seem to come up on the intellisense but for some reason JSON is available when it previously was..

The error i'm getting is

Use of undeclared type JSON

This is the format of my data in a blank swift file it's worth note mentioning that using the word JSON doesn't turn green like it normally should.

var data: JSON = [

    "stories" : [

        [
            "Article_Link" : "http://www.webdesignernews.com/redirect?url=http%3A%2F%2Fwww.creativebloq.com%2Fweb-design%2Fweb-designers-take-centre-stage-new-sitcom-91516753",
            "Article_Shares" : "",
            "Article_Time" : "44 min ago",
            "Article_Title" : "Web Designers Take Centre Stage in New Sitcom",
            "icon" : "Web-Designer-Depot",
            "index" : 2,
            "source" : "Web Designer Depot",
            "url" : "http://www.webdesignernews.com/",
        ],
        [
            "Article_Link" : "http://www.webdesignernews.com/redirect?url=http%3A%2F%2Fwww.webdesignerdepot.com%2F2015%2F09%2Fwhats-new-for-designers-september-2015%2F",
            "Article_Shares" : "203",
            "Article_Time" : "50 min ago",
            "Article_Title" : "What's New for Designers, September 2015",
            "icon" : "Web-Designer-Depot",
            "index" : 3,
            "source" : "Web Designer Depot",
            "url" : "http://www.webdesignernews.com/",
        ],
        [
            "Article_Link" : "http://www.webdesignernews.com/redirect?url=http%3A%2F%2Fblog.atomic.io%2Fnews%2Fadvanced-motion-control-now-in-atomic%2F",
            "Article_Shares" : "68",
            "Article_Time" : "1 hour ago",
            "Article_Title" : "New in Atomic Prototype with Advanced Motion Control + Swipe Gestures",
            "icon" : "Web-Designer-Depot",
            "index" : 4,
            "source" : "Web Designer Depot",
            "url" : "http://www.webdesignernews.com/",
        ]

       ]
    ]

Upvotes: 1

Views: 979

Answers (1)

Abhinav
Abhinav

Reputation: 38142

Compiler have all rights to throw that error. There is no data type called JSON existing in Swift. You should use dictionary instead.

Upvotes: 1

Related Questions