Guest User

Untitled

a guest
Feb 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. struct JSON: Decodable {
  2. let block1: Format
  3. let block2: Format
  4. let block3: Format
  5. }
  6.  
  7. struct Format: Decodable {
  8. let metadata: MetaData //[String: Any]
  9. let columns: [String] // columns names
  10. let data: [[Any]] // data of type in metadata
  11. }
  12.  
  13. struct MetaData: Decodable {
  14.  
  15. enum CodingKeys: String, CodingKey {
  16. case type, bytes
  17. case maxSize = "max_size"
  18. }
  19.  
  20. let type: String
  21. let bytes: Int?
  22. let maxSize: Int?
  23.  
  24. init(from decoder: Decoder) throws {
  25. let container = try decoder.container(keyedBy: CodingKeys.self)
  26.  
  27. self.type = try container.decode(String.self, forKey: .type)
  28. self.bytes = try container.decode(Int.self, forKey: .bytes)
  29. self.maxSize = try container.decode(Int.self, forKey: .maxSize)
  30. }
  31. }
Add Comment
Please, Sign In to add comment