{
"definitions": {
"Student": {
"description": "A simple student struct",
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
},
"root": "Student"
}
// A simple student struct
class Student: Codable {
var firstName: String
var lastName: String
var age: Int
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
}
}
{
"definitions": {
"Human": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"Student": {
"parent": {
"type": "reference",
"target": "Human"
},
"type": "struct",
"properties": {
"studentId": {
"type": "string"
}
}
}
},
"root": "Student"
}
class Human: Codable {
var firstName: String
var lastName: String
var age: Int
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
}
}
class Student: Human {
var studentId: String
enum CodingKeys: String, CodingKey {
case studentId = "studentId"
}
}
{
"definitions": {
"Student": {
"description": "A student struct with an assigned faculty",
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"faculty": {
"type": "reference",
"target": "Faculty"
}
}
},
"Faculty": {
"type": "struct",
"properties": {
"name": {
"type": "string"
}
}
}
},
"root": "Student"
}
// A student struct with an assigned faculty
class Student: Codable {
var firstName: String
var lastName: String
var age: Int
var faculty: Faculty
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
case faculty = "faculty"
}
}
class Faculty: Codable {
var name: String
enum CodingKeys: String, CodingKey {
case name = "name"
}
}
{
"definitions": {
"Student": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
},
"properties": {
"type": "map",
"schema": {
"type": "string"
}
}
}
}
},
"root": "Student"
}
class Student: Codable {
var firstName: String
var lastName: String
var age: Int
var properties: Dictionary<String, String>
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case age = "age"
case properties = "properties"
}
}
{
"definitions": {
"Human": {
"type": "struct",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"location": {
"type": "reference",
"target": "Location"
}
}
},
"Location": {
"type": "struct",
"base": true,
"properties": {
"type": {
"type": "string"
}
},
"discriminator": "type",
"mapping": {
"Web": "web",
"World": "world"
}
},
"Web": {
"parent": {
"type": "reference",
"target": "Location"
},
"type": "struct",
"properties": {
"url": {
"type": "string"
}
}
},
"World": {
"parent": {
"type": "reference",
"target": "Location"
},
"type": "struct",
"properties": {
"lat": {
"type": "string"
},
"long": {
"type": "string"
}
}
}
},
"root": "Human"
}
class Human: Codable {
var firstName: String
var lastName: String
var location: Location
enum CodingKeys: String, CodingKey {
case firstName = "firstName"
case lastName = "lastName"
case location = "location"
}
}
class Location: Codable {
var _type: String
enum CodingKeys: String, CodingKey {
case _type = "type"
}
}
class Web: Location {
var url: String
enum CodingKeys: String, CodingKey {
case url = "url"
}
}
class World: Location {
var lat: String
var long: String
enum CodingKeys: String, CodingKey {
case lat = "lat"
case long = "long"
}
}
{
"definitions": {
"Student": {
"type": "struct",
"properties": {
"matricleNumber": {
"type": "integer"
}
}
},
"StudentMap": {
"type": "struct",
"parent": {
"type": "reference",
"target": "Map",
"template": {
"T": "Student"
}
}
},
"Map": {
"type": "struct",
"properties": {
"totalResults": {
"type": "integer"
},
"entries": {
"type": "array",
"schema": {
"type": "generic",
"name": "T"
}
}
}
}
},
"root": "StudentMap"
}
class Student: Codable {
var matricleNumber: Int
enum CodingKeys: String, CodingKey {
case matricleNumber = "matricleNumber"
}
}
class Map<T>: Codable {
var totalResults: Int
var entries: Array<T>
enum CodingKeys: String, CodingKey {
case totalResults = "totalResults"
case entries = "entries"
}
}
class StudentMap: Map<Student> {
enum CodingKeys: String, CodingKey {
}
}
{
"import": {
"my_ns": "file:///generic.json"
},
"definitions": {
"Faculty": {
"type": "struct",
"properties": {
"description": {
"type": "string"
},
"students": {
"type": "array",
"schema": {
"type": "reference",
"target": "my_ns:StudentMap"
}
}
}
}
},
"root": "Faculty"
}
class Faculty: Codable {
var description: String
var students: Array<StudentMap>
enum CodingKeys: String, CodingKey {
case description = "description"
case students = "students"
}
}