Swift 2.1:无法使用ObjectMapper将JSON对象映射到领域对象

Swift 2.1:无法使用ObjectMapper将JSON对象映射到领域对象,swift,swift2,realm,swifty-json,objectmapper,Swift,Swift2,Realm,Swifty Json,Objectmapper,我试图使用ObjectMapper将我的JSON对象映射到一个领域对象,但结果一直是零 import RealmSwift import ObjectMapper class Notification: Object, Mappable { dynamic var id = 0 dynamic var isProcessed = false dynamic var type = "" var supersedes : Int? required convenience init?(_ map

我试图使用ObjectMapper将我的JSON对象映射到一个领域对象,但结果一直是零

import RealmSwift
import ObjectMapper

class Notification: Object, Mappable {
dynamic var id = 0
dynamic var isProcessed = false
dynamic var type = ""
var supersedes : Int?

required convenience init?(_ map: Map) {
    self.init()
}

// Mappable
func mapping(map: Map) {
    id <- map["id"]
    isProcessed <- map["isProcessed"]
    type <- map["type"]
    supersedes <- map["supersedes"]
}
}
导入RealmSwift
导入对象映射器
类通知:对象,可映射{
动态变量id=0
动态变量isProcessed=false
动态变量类型=“”
var替代:Int?
所需便利初始化(umap:map){
self.init()
}
//可映射
func映射(映射:映射){

id不能以这种方式组合ObjectMapper和SwiftyJSON。 您可以将SwityJSON
JSON
struct中的
rawValue
作为参数提供给ObjectMapper的
Mapper.map
,或者只使用它

let notif = Mapper<Notification>().map(notification) // notif here is nil
  {
        data =             {
            buyerInfo =                 {
                image = "";
                name = "";
                userId = UID2268351488;
            };
            sellerSKUs =                 (
                                    {
                    id = SSK236123228808967424;
                    price =                         {
                        amount = 888;
                        currency = THB;
                    };
                    quantity = 2;
                },
                                    {
                    id = SSK563365068895040768;
                    price =                         {
                        amount = 6865;
                        currency = THB;
                    };
                    quantity = 1;
                }
            );
            subOrderId = SOD751798094080240;
        };
        id = 39038;
        isProcessed = 0;
        supersedes = "<null>";
        type = PendingSubOrderConfirmationNotification;
    },