bignerdranch / Freddy

A reusable framework for parsing JSON in Swift.
MIT License
1.09k stars 119 forks source link

Parse - [NSObject: AnyObject] #185

Closed YMonnier closed 7 years ago

YMonnier commented 8 years ago

Hello,

I am facing a problem about the Freddy Json Parser. I would like to parse a JSON response from the didReceiveRemoteNotification function.

I cannot parse directly the userInfo response.

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
   let json = JSON(userInfo)
  }

Have yo any ideas? Thank you. :-)

jgallagher commented 8 years ago

Freddy actually includes the code needed to do this conversion, but to date we've intentionally kept it private because it is very slow for large payloads, and we wanted to encourage folks to use Freddy's parser rather than going through NSJSONSerialization and then the slow conversion. Your use case isn't one we had considered when making that decision, though. For now, a workaround could be that you could copy our implementation of this conversion (from https://github.com/bignerdranch/Freddy/blob/master/Sources/JSONParsing.swift#L52-L124) into your project. We'll discuss making this converter public again soon.

radex commented 8 years ago

Same issue — and same use case. Except now it's [AnyHashable: Any]...

YMonnier commented 7 years ago

@radex Thank you for the pull request!