{"id":30029925,"url":"https://github.com/mattt/ontology","last_synced_at":"2026-06-07T15:30:55.233Z","repository":{"id":279874414,"uuid":"940288254","full_name":"mattt/Ontology","owner":"mattt","description":"A Swift library for working with structured data.","archived":false,"fork":false,"pushed_at":"2025-10-16T16:49:53.000Z","size":65,"stargazers_count":44,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-05T09:21:09.604Z","etag":null,"topics":["json-ld","schema-org"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-27T23:21:57.000Z","updated_at":"2026-05-25T15:47:29.000Z","dependencies_parsed_at":"2025-12-04T15:03:47.324Z","dependency_job_id":null,"html_url":"https://github.com/mattt/Ontology","commit_stats":null,"previous_names":["loopwork-ai/ontology","mattt/ontology","loopwork/ontology"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/mattt/Ontology","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattt%2FOntology","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattt%2FOntology/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattt%2FOntology/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattt%2FOntology/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattt","download_url":"https://codeload.github.com/mattt/Ontology/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattt%2FOntology/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34027670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-ld","schema-org"],"created_at":"2025-08-06T18:10:04.193Z","updated_at":"2026-06-07T15:30:55.216Z","avatar_url":"https://github.com/mattt.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ontology\n\nA Swift library for working with structured data.\nThis library provides [JSON-LD][json-ld] serializable types\nthat can represent entities from various vocabularies,\nwith a focus on [Schema.org][schema.org].\nIt includes convenience initializers for types from Apple frameworks, like\n[Contacts][framework-contacts] and [EventKit][framework-eventkit].\n\n## Requirements\n\n- Swift 6.0+ / Xcode 16+\n- macOS 14.0+ (Sonoma)\n- iOS 17.0+\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/mattt/Ontology.git\", from: \"0.8.0\")\n]\n```\n\n## Supported Types\n\n### Schema.org Vocabulary\n\nSupported Schema.org types and their Apple framework equivalents:\n\n| Schema.org Type | Apple Framework Type | Description |\n|----------------|----------------------|-------------|\n| [ContactPoint](https://schema.org/ContactPoint) | [CNInstantMessageAddress](https://developer.apple.com/documentation/contacts/cninstantmessageaddress) | Represents a method of contact like instant messaging |\n| [DateTime](https://schema.org/DateTime) | [Date](https://developer.apple.com/documentation/foundation/date) | Represents a date and time with ISO 8601 formatting |\n| [Event](https://schema.org/Event) | [EKEvent](https://developer.apple.com/documentation/eventkit/ekevent) | Represents an event with start/end dates, location, etc. |\n| [GeoCoordinates](https://schema.org/GeoCoordinates) | [CLLocation](https://developer.apple.com/documentation/corelocation/cllocation) | Represents geographic coordinates with latitude, longitude, and optional elevation |\n| [Organization](https://schema.org/Organization) | [CNContact](https://developer.apple.com/documentation/contacts/cncontact) | Represents an organization with properties like name and contact info |\n| [Person](https://schema.org/Person) | [CNContact](https://developer.apple.com/documentation/contacts/cncontact) | Represents a person with properties like name, contact info, and relationships |\n| [Place](https://schema.org/Place) | [MKPlacemark](https://developer.apple.com/documentation/mapkit/mkplacemark), [MKMapItem](https://developer.apple.com/documentation/mapkit/mkmapitem) | Represents a geographical location, specific address, or point of interest |\n| [ItemList](https://schema.org/ItemList) | [EKCalendar](https://developer.apple.com/documentation/eventkit/ekcalendar) | Represents a list of items with properties like name, identifier, and item count |\n| [PlanAction](https://schema.org/PlanAction) | [EKReminder](https://developer.apple.com/documentation/eventkit/ekreminder) | Represents a planned action or task with properties like name, description, due date, and completion status |\n| [PostalAddress](https://schema.org/PostalAddress) | [CNPostalAddress](https://developer.apple.com/documentation/contacts/cnpostaladdress) | Represents a physical address with street, city, region, etc. |\n| [QuantitativeValue](https://schema.org/QuantitativeValue) | [Measurement](https://developer.apple.com/documentation/foundation/measurement) | Represents measurements with standardized units using UN/CEFACT Common Codes |\n| [Trip](https://schema.org/Trip) | [MKDirections.Response](https://developer.apple.com/documentation/mapkit/mkdirections/response), [MKDirections.ETAResponse](https://developer.apple.com/documentation/mapkit/mkdirections/etaresponse) | Represents an itinerary of visits to one or more places with optional arrival/departure times |\n\n### Apple WeatherKit Vocabulary\n\nAdditional types supporting [Apple WeatherKit][weatherkit]:\n\n| Type | WeatherKit Type | Description |\n|------|----------------|-------------|\n| WeatherForecast | [DayWeather](https://developer.apple.com/documentation/weatherkit/dayweather), [HourWeather](https://developer.apple.com/documentation/weatherkit/hourweather), [MinuteWeather](https://developer.apple.com/documentation/weatherkit/minuteweather) | Detailed weather forecast including temperature, precipitation, wind, sun/moon data |\n| WeatherConditions | [CurrentWeather](https://developer.apple.com/documentation/weatherkit/currentweather), [HourWeather](https://developer.apple.com/documentation/weatherkit/hourweather) | Current or hourly weather conditions including temperature, wind, and humidity |\n\n## Usage\n\n### Creating objects and encoding as JSON-LD\n\n```swift\nimport Ontology\n\n// Create a Person\nvar person = Person()\nperson.givenName = \"John\"\nperson.familyName = \"Doe\"\nperson.email = [\"john.doe@example.com\"]\n\n// Create an organization\nvar organization = Organization()\norganization.name = \"Example Corp\"\n\n// Associate person with organization\nperson.worksFor = organization\n\n// Encode to JSON-LD\nlet encoder = JSONEncoder()\nlet jsonData = try encoder.encode(person)\nprint(String(data: jsonData, encoding: .utf8)!)\n\n// Output:\n// {\n//   \"@context\": \"https://schema.org\",\n//   \"@type\": \"Person\",\n//   \"givenName\": \"John\",\n//   \"familyName\": \"Doe\"\n// }\n```\n\n### Initializing from Apple framework types\n\n```swift\nimport Ontology\nimport Contacts\n\n// Convert from Apple's CNContact to Schema.org Person\nlet contact = CNMutableContact()\ncontact.givenName = \"Jane\"\ncontact.familyName = \"Smith\"\ncontact.emailAddresses = [\n    CNLabeledValue(label: CNLabelHome,\n                   value: \"jane.smith@example.com\" as NSString)\n]\n\n// Convert to Schema.org Person\nlet person = Person(contact)\n```\n\n### Configuring DateTime representations\n\nBy default, `DateTime` objects are encoded with their specified time zone,\nor GMT/UTC if none is specified.\nYou can override the time zone used during encoding by providing\na specific `TimeZone` in the `JSONEncoder`'s `userInfo` dictionary:\n\n```swift\nimport Ontology\n\n// Create a DateTime object\nlet dateTime = DateTime(Date())\n\n// Create an encoder that will use the local timezone\nlet encoder = JSONEncoder()\nencoder.userInfo[DateTime.timeZoneOverrideKey] = TimeZone.current\n\n// Or specify a particular timezone\n// encoder.userInfo[DateTime.timeZoneOverrideKey] = TimeZone(identifier: \"America/New_York\")\n\n// Encode using the specified timezone\nlet jsonData = try encoder.encode(dateTime)\n```\n\nThis feature is particularly useful when:\n- Working with date-only values that should be interpreted in the user's local timezone\n- Ensuring consistent timezone representation across different data sources\n- Presenting dates to users in their local timezone regardless of how they were originally stored\n\nSo to recap, the date encoding priority is:\n1. `TimeZone` from encoder's `userInfo` (if provided)\n2. `TimeZone` from the `DateTime` object (if specified)\n3. GMT/UTC (default fallback)\n\n## License\n\nThis project is available under the MIT license.\nSee the LICENSE file for more info.\n\n## Legal\n\nApple Weather and Weather are trademarks of Apple Inc.\nThis project is not affiliated with, endorsed, or sponsored by Apple Inc.\n\n[schema.org]: https://schema.org\n[json-ld]: https://json-ld.org\n[nws-api]: https://weather.gov\n[framework-contacts]: https://developer.apple.com/documentation/contacts/\n[framework-eventkit]: https://developer.apple.com/documentation/eventkit\n[weatherkit]: https://developer.apple.com/weatherkit/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattt%2Fontology","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattt%2Fontology","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattt%2Fontology/lists"}