Get Updates By E-mail 

Article Written By:
Johann Dowa

Swift Library For Easily Encoding Classes, Structs, And Enums To JSON Data

  •  
  •  
  •  
  •  
  •  

Wrap is a Swift library from John Sundell easily encode Swift classes, structs or enums as JSON data.

The key advantage of Wrap is the simplicity, and for more advanced objects that may not have simple data types  you can create custom keys, and key types.

This code snippet from the readme shows how one could encode a simple object:

struct User {
    let name: String
    let age: Int
}

let user = User(name: "John", age: 28)

let dictionary: [String : AnyObject] = try Wrap(user)

This would produce the Dictionary with the data:

{
    "name": "John",
    "age": 28
}

You can find Wrap on Github here.

A nice simple way to encode Swift data as JSON.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments