1

I'm trying to use this FunctionalJSON-swift to parse JSON to object but I can't figure out how to use method performRequest from NetworkClient and obtain my User object. This is what I have:

let url = NSURL(string: "http://localhost/my_app/user.json")
let request = NSMutableURLRequest(URL: url)

request.HTTPMethod = "GET"

performRequest(request, callback: { (data: Result<User>) -> () in
    // how obtain User?
})

This is output from url, I think it's all right at this point:

{"id":1,"name":"User Name","email":"[email protected]"}

1 Answer 1

1

First of all, I apologize if this is not the type of answer you seek, as I am going to do this using another library but in a really quick manner thanks to it.

It is actually a library that I wrote based on the ideas on that repo's blog post. You can get it here: JSONHelper

As to the answer: Just get the response as a string and, let's assume that it is stored in a string variable named responseString, deserialize it like this:

var user: User?
user <<<< responseString
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, I used your library and it worked perfectly. Do you have any plans for improvements to accept values ​​as NSDate and NSData?
I do for NSDate and NSURL. I'll add NSData to my future plans, thanks for the suggestion. ^^

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.