{"id":13872220,"url":"https://github.com/mongodb/swift-bson","last_synced_at":"2026-03-06T01:02:27.262Z","repository":{"id":37561933,"uuid":"125097454","full_name":"mongodb/swift-bson","owner":"mongodb","description":"pure Swift BSON library","archived":false,"fork":false,"pushed_at":"2023-04-10T12:35:24.000Z","size":2192,"stargazers_count":50,"open_issues_count":3,"forks_count":22,"subscribers_count":29,"default_branch":"main","last_synced_at":"2026-01-21T08:36:45.583Z","etag":null,"topics":["bson","mongodb","swift"],"latest_commit_sha":null,"homepage":"https://mongodb.github.io/swift-bson","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongodb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-03-13T18:32:56.000Z","updated_at":"2025-12-06T14:36:35.000Z","dependencies_parsed_at":"2024-01-16T10:09:28.065Z","dependency_job_id":null,"html_url":"https://github.com/mongodb/swift-bson","commit_stats":{"total_commits":107,"total_committers":12,"mean_commits":8.916666666666666,"dds":0.7383177570093458,"last_synced_commit":"de94473c2b872334937117af19c6c5f3e810e0ab"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mongodb/swift-bson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fswift-bson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fswift-bson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fswift-bson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fswift-bson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb","download_url":"https://codeload.github.com/mongodb/swift-bson/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fswift-bson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30156850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"ssl_error","status_checked_at":"2026-03-05T22:39:24.771Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bson","mongodb","swift"],"created_at":"2024-08-05T23:00:37.181Z","updated_at":"2026-03-06T01:02:27.212Z","avatar_url":"https://github.com/mongodb.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Swift BSON\n\n![swift-bson-logo](etc/swiftBSON.png)\n\nThe official MongoDB BSON implementation in Swift!\n\n## Index\n\n- [Bugs/Feature Requests](#bugs--feature-requests)\n- [Installation](#installation)\n- [Example Usage](#example-usage)\n  - [Work With and Modify Documents](#work-with-and-modify-documents)\n- [Development Instructions](#development-instructions)\n\n## Bugs / Feature Requests\n\nThink you've found a bug? Want to see a new feature in `swift-bson`? Please open a case in our issue management tool, JIRA:\n\n1. Create an account and login: [jira.mongodb.org](https://jira.mongodb.org)\n2. Navigate to the SWIFT project: [jira.mongodb.org/browse/SWIFT](https://jira.mongodb.org/browse/SWIFT)\n3. Click **Create Issue** - Please provide as much information as possible about the issue and how to reproduce it.\n\nBug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) and the Core Server (i.e. SERVER) project are **public**.\n\n## Installation\n\nThe library supports use with Swift 5.1+. The minimum macOS version required to build the library is 10.14. The library is tested in continuous integration against macOS 10.14, Ubuntu 16.04, and Ubuntu 18.04.\n\nInstallation is supported via [Swift Package Manager](https://swift.org/package-manager/).\n\n### Install BSON\n\nTo install the library, add the package as a dependency in your project's `Package.swift` file:\n\n```swift\n// swift-tools-version:5.1\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyPackage\",\n    dependencies: [\n        .package(url: \"https://github.com/mongodb/swift-bson\", .upToNextMajor(from: \"3.1.0\"))\n    ],\n    targets: [\n        .target(name: \"MyTarget\", dependencies: [\"SwiftBSON\"])\n    ]\n)\n```\n\n## Example Usage\n\n### Work With and Modify Documents\n\n```swift\nimport SwiftBSON\n\nvar doc: BSONDocument = [\"a\": 1, \"b\": 2, \"c\": 3]\n\nprint(doc) // prints `{\"a\" : 1, \"b\" : 2, \"c\" : 3}`\nprint(doc[\"a\", default: \"Not Found!\"]) // prints `.int64(1)`\n\n// Set a new value\ndoc[\"d\"] = 4\nprint(doc) // prints `{\"a\" : 1, \"b\" : 2, \"c\" : 3, \"d\" : 4}`\n\n// Using functional methods like map, filter:\nlet evensDoc = doc.filter { elem in\n    guard let value = elem.value.asInt() else {\n        return false\n    }\n    return value % 2 == 0\n}\nprint(evensDoc) // prints `{ \"b\" : 2, \"d\" : 4 }`\n\nlet doubled = doc.map { elem -\u003e Int in\n    guard case let value = .int64(value) else {\n        return 0\n    }\n\n    return Int(value * 2)\n}\nprint(doubled) // prints `[2, 4, 6, 8]`\n```\n\nNote that `BSONDocument` conforms to `Collection`, so useful methods from [`Sequence`](https://developer.apple.com/documentation/swift/sequence) and [`Collection`](https://developer.apple.com/documentation/swift/collection) are all available. However, runtime guarantees are not yet met for many of these methods.\n\n## Development Instructions\n\nSee our [development guide](https://github.com/mongodb/mongo-swift-driver/blob/main/Guides/Development.md) for the MongoDB driver to get started.\nTo run the tests for the BSON library you can make use of the Makefile and run: `make test-pretty` (uses `xcpretty` to change the output format) or just `make test` (for environments without ruby).\n\n## Note\n\nThis repository previously contained Swift bindings for libbson, the MongoDB C driver's BSON library. Those bindings are still available under the 2.1.0 tag. Major version 3.0 and up will be used for the BSON library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fswift-bson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb%2Fswift-bson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fswift-bson/lists"}