dankogai / swift-json

Even Swiftier JSON Handler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Init with string gives nil

LinusGeffarth opened this issue · comments

commented

I'm trying to init JSON using JSON(string: String) but when printing the json variable as string, it says nil.

Now, the string I'm using is valid. I verified that by uploading it to my server and then initializing JSON using JSON(url: String). That printed as string gives me the right result.

Any ideas / workarounds? Thanks!

commented

Nevermind, it only printed nil because I was doing print(JSON(string: myStr).asString). This, however, works: print(JSON(string: myStr))