JSONDecoder: saving raw JSON for some fields

Viewed 377

I am using JSONDecoder to save my JSON data into objects. But I would like some part of the JSON to be saved as is. Is that possible?

Say this is my JSON

"customer": {  
     "personal": {  
        "name": "John Doe",  
        "misc": {  
            "active": “true”,  
            "addons": {  
              "country": "USA",
              "state": "Michigan"
            },  
        "customer_id": "1234"   
        }    
    },  
    "source": "main"  
}

And I map all data as

class Customer {  
   let personal: Personal
   let source: String  
}   

class Personal {  
    let name: String
    let customer_id: String 
    let misc: String // I want this to be saved as just raw json
} 

How can I parse the JSON so that misc is saved as just raw JSON which I can use later?

0 Answers
Related