SwiftyJSON icon indicating copy to clipboard operation
SwiftyJSON copied to clipboard

Null Response Parsing with SwiftyJSON

Open arashgood opened this issue 8 years ago • 3 comments

I have a json response from Alamofire like below: let json: JSON = {
"PathRoute":{.....}, "SharedServicePrice":"2600", "PrivateServicePrice":"13200", "Tap30PathPrice":null, "SnappServicePrice":null, "SnappBikeServicePrice":null, "SnappRoseServicePrice":null }

and it's type is JSON(swiftyJSON type)

when i want to parse "PathRoute" it returns null!!

let pathRoute =json["PathRoute"] print(pathRoute) ---> null i checked everything doesn't work again

using:

  • SwiftyJSON: 4.0.0
  • Xcode Version:9.2
  • Swift Version: 4.0

arashgood avatar Feb 24 '18 07:02 arashgood

I am having a similar issue. My JSON is valid, and when I do print(json.description) and print(json.debugDescription) it shows me my JSON string, but when I try to get attributes from the JSON it does not work.

EDIT: I was using Alamofire and was using responseString instead of responseJSON. My problem is fixed now.

enzowritescode avatar Mar 13 '18 16:03 enzowritescode

@arashgood Did you have the same issue that @logalleg had? I did. Following logalleg's suggestion fixed that same issue for me.

AndrewBudziszek avatar Jun 11 '18 14:06 AndrewBudziszek

Are you guys using Alamofire.JSON instead of SwiftyJSON.JSON ?

wongzigii avatar Jun 13 '18 14:06 wongzigii