by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    magellan314
    @magellan314
    Hi, I am trying to implement your "JSONHelper.swift" project to parse a nested JSONString (from my PHP web page). I have setup the class structure for the data per your tutorial; however, the nested deserializable object always returns "nil". Any ideas?
    Baris Sencan
    @isair
    I can help out if you can show me your JSON data and classes.
    Send me a mail at barissncn@gmail.com
    magellan314
    @magellan314
    Hi, I just sent you an email. Let me know if it didn't come through from the attachment. Thanks again!
    ashwin
    @ashmoi
    Hi
    I am using JSONHelper
    Optional({
    retrunStatus = {
    status = "User successfully authenticated ";
    };
    user = {
    fullname = "Ashwin Moily";
    id = 1;
    mobile = 1234567890;
    password = "";
    role = 1;
    username = "ashwin@gmail.com";
    };
    })
    This is the result I am getting from JSON
    I have created three model class

    class User : Deserializable{
    var fullname: String?
    var id: Int?
    var mobile : Double?
    var role : Int?
    var username : String?

    required init(data: [String: AnyObject]) {
        fullname <<< data["fullname"]
        id <<< data["id"]
        mobile <<< data["mobile"]
        role <<< data["role"]
        username <<< data["username"]
    }

    }

    Second model class

    class ReturnStatus : Deserializable {
    var status :String?

    required init(data: [String: AnyObject]) {
        status <<< data["status"]
    }

    }

    Third model class class LoginResult : Deserializable {

    var user :user?
    var returnStatus :ReturnStatus?
    
    required init(data: [String: AnyObject]) {
        returnStatus <<<< data["returnStatus"]
        user <<<< data["user"]
    }

    }

    ashwin
    @ashmoi
    I am using Alamofire to call rest API
    I am able to do call this
    Alamofire.request(.POST, Constant.apiUrl, parameters: ["username": us , "password" : pw])
    .responseJSON { (, _, JSON, ) in
    println(JSON)
                var loginResult: LoginResult?
    
                 loginResult <<<< JSON
    LoginResult? does not have a member named returnStatus
    Baris Sencan
    @isair
    If the last line you wrote is an error you see in the console, then I think you are trying to access it as loginResult.returnStatus instead of loginResult?.returnStatus or loginResult!.returnStatus
    Andreas
    @anohren

    Hi, thanks for the library, it works well. I managed to use inheritance in my model objects, but thought I'd propose a challenge to support protocol type properties. They're not instantiable in the way JSONHelper currently does things.

    I

    This message was deleted
    Andreas
    @anohren
    Not in desperate need for that functionality, but mostly wondering if you know of any pattern that could nicely decouple the concrete type information from the class that is declaring the reference to a (protocol) type?
    Baris Sencan
    @isair
    Sorry for replying a bit late, I will take a look into this soon.
    Peyman Mortazavi
    @peymanmortazavi
    any idea when the new version will come out?
    I'm using Xcode 7.3 and there is a bug with parsing NSURL?s but it's already addressed in the last commit
    but it's not in the cocoapods yet
    so I'm wondering when it'll be out
    Baris Sencan
    @isair
    2.0.0 will be out in a few days latest. isair/JSONHelper#56
    Baris Sencan
    @isair
    The dev-2.0.0 should be ready for production now, people. I'll update the README and documentations within the next day and do a release. If you need it urgently just specify JSONHelper to use dev-2.0.0 branch in your Podfile.