{"id":37029619,"url":"https://github.com/jershell/kbson","last_synced_at":"2026-01-14T03:34:05.880Z","repository":{"id":49309385,"uuid":"200860049","full_name":"jershell/kbson","owner":"jershell","description":"Mongo BSON support for kotlinx.serialization.","archived":false,"fork":false,"pushed_at":"2024-06-25T16:48:07.000Z","size":274,"stargazers_count":42,"open_issues_count":6,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-06-25T18:32:18.401Z","etag":null,"topics":["bson","kotlin","kotlinx","serialization"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/jershell.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-06T13:44:44.000Z","updated_at":"2024-06-25T16:48:11.000Z","dependencies_parsed_at":"2024-06-25T18:17:03.983Z","dependency_job_id":"e79341f5-ffa3-4ca6-8732-3ec7dcb9bf39","html_url":"https://github.com/jershell/kbson","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/jershell/kbson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fkbson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fkbson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fkbson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fkbson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jershell","download_url":"https://codeload.github.com/jershell/kbson/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fkbson/sbom","scorecard":{"id":516208,"data":{"date":"2025-08-11","repo":{"name":"github.com/jershell/kbson","commit":"70284269b7efb4595a5fcdd25ca85abcd0d07b85"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":2,"reason":"Found 5/23 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T01:53:26.651Z","repository_id":49309385,"created_at":"2025-08-20T01:53:26.651Z","updated_at":"2025-08-20T01:53:26.651Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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":["bson","kotlin","kotlinx","serialization"],"created_at":"2026-01-14T03:34:05.225Z","updated_at":"2026-01-14T03:34:05.868Z","avatar_url":"https://github.com/jershell.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Maven Central](https://img.shields.io/maven-central/v/com.github.jershell/kbson)  ![Bintray](https://img.shields.io/bintray/v/jershell/generic/kbson?label=jcenter)\n\n# kbson\n\n# What is this?\nThis adapter adds BSON support to kotlinx.serialization.\n\nBSON types supported:\n\n- Double\t \n- String \n- Array\n- Binary \n- UUID\n- ObjectId\n- Boolean\n- Date\n- Symbol\n- 32-bit integer\n- Long\n- Decimal128\n\n\n## Install\n\nbuild.gradle.kts\n```kotlin\ndependencies {\n    // kotlin 1.9.24 \u0026 kotlinx.serialization 1.6.3\n    implementation(\"com.github.jershell:kbson:0.7.0\")\n    \n    // kotlin 1.7.20 \u0026 kotlinx.serialization 1.4.1\n    implementation(\"com.github.jershell:kbson:0.6.0\")\n    \n    // kotlin 1.6.21 \u0026 kotlinx.serialization 1.3.3\n    implementation(\"com.github.jershell:kbson:0.4.6\")\n\n\n    // kotlin 1.4.20 \u0026 kotlinx.serialization 1.0.1\n    implementation(\"com.github.jershell:kbson:0.4.4\")\n    \n    // kotlin 1.3\n    implementation(\"com.github.jershell:kbson:0.3.0\")\n}\n```\n\nor\n\nbuild.gradle\n```groovy\ndependencies {\n    // kotlin 1.9.24 \u0026 kotlinx.serialization 1.6.3\n    implementation 'com.github.jershell:kbson:0.7.0'\n\n    // kotlin 1.7.20 \u0026 kotlinx.serialization 1.4.1\n    implementation 'com.github.jershell:kbson:0.5.0'\n    \n    // kotlin 1.7.20 \u0026 kotlinx.serialization 1.4.1\n    implementation 'com.github.jershell:kbson:0.5.0'\n    \n    // kotlin 1.6.21 \u0026 kotlinx.serialization 1.3.3\n    implementation 'com.github.jershell:kbson:0.4.6'\n    \n    \n    // kotlin 1.4.20 \u0026 kotlinx.serialization 1.0.1\n    implementation 'com.github.jershell:kbson:0.4.4'\n    \n    \n    // kotlin 1.3\n    implementation 'com.github.jershell:kbson:0.3.0'\n}\n```\n\n\n# Usage samples\n##### Parsing from BSON to a Kotlin object\n\n```kotlin\nimport kotlinx.serialization.Serializable\nimport com.github.jershell.kbson.ObjectIdSerializer\n\nval kBson = KBson()\n\n\n@Serializable\ndata class Simple (\n        val valueString: String,\n\n        val valueDouble: Double,\n\n        val valueFloat: Float,\n\n        val valueLong: Long,\n\n        val valueChar: Char,\n\n        val valueBool: Boolean,\n\n        @NonEncodeNull\n        @ContextualSerialization\n        val _id: ObjectId? = null,\n\n        @ContextualSerialization\n        val uuid: UUID,\n\n        val valueInt: Int\n)\n\nval simple = kBson.parse(Simple.serializer(), bsonDocFromMongoJavaDriver)\n```\n\n##### Serializing from a Kotlin object to BSON\n```kotlin\nimport kotlinx.serialization.Serializable\nimport com.github.jershell.kbson.Configuration\nimport com.github.jershell.kbson.KBson\nimport com.github.jershell.kbson.ObjectIdSerializer\n\n@Serializable\ndata class Simple (\n        val valueString: String = \"default\",\n        val valueDouble: Double,\n        val valueFloat: Float,\n        val valueLong: Long,\n        val valueChar: Char,\n        val valueBool: Boolean,\n        @NonEncodeNull\n        @ContextualSerialization \n        val _id: ObjectId? = null,\n        val valueInt: Int\n)\n\n// Optional configuration\nval kBson = KBson(Configuration(encodeDefaults = false))\nval bsonDoc = kBson.stringify(Simple.serializer(), simpleModel)\n\n// You can override default serializers or add your serializer  \nval kBson = KBson(context = serializersModuleOf(mapOf(\n            ObjectId::class to ObjectIdSerializer,\n            Date::class to DateSerializer\n    )))\n    \n// You can use load and dump with ByteArray \nval simple = kBson.load(Simple.serializer(), bsonDoc)\n// also\nval simple2 = kBson.load(Simple.serializer(), bsonDoc.toByteArray())\n// !!!! The method load() use BsonDecoder and strict order of fields\n\n```\n[See the tests for more examples](https://github.com/jershell/kbson/blob/master/src/test/kotlin/com/github/jershell/kbson/KBsonTest.kt) \n## API\n```kotlin\nval kBson = KBson()\n\nkBson.parse(deserializer: DeserializationStrategy\u003cT\u003e, doc: BsonDocument) :T\n// !!!! The method load() use BsonDecoder and strict order of fields\n// https://docs.mongodb.com/manual/tutorial/update-documents/#field-order\nkBson.load(deserializer: DeserializationStrategy\u003cT\u003e, doc: ByteArray): T\nkBson.load(deserializer: DeserializationStrategy\u003cT\u003e, doc: BsonDocument): T\n\nkBson.stringify(): BsonDocument\nkBson.dump(serializer: SerializationStrategy\u003cT\u003e, obj: T): ByteArray\n\n// Extension functions \nBsonDocument.toByteArray(): ByteArray\nBsonDocument.toDocument(): Document\n```\n\n### Configuration\n```\nclassDiscriminator = \"___type\" // name of the class descriptor property in polymorphic serialization.\nencodeDefaults = \"true\" // specifies whether default values are encoded.\n```\n###### ps\n@NonEncodeNull useful for item _id mongodb\n\nThe default enum class supported like string. You can also override it\n\nkbson before 0.1.5 use kotlinx.serialization 0.11.x\n\nkbson after 0.1.5 use kotlinx.serialization 0.13.x\n\nkbson after 0.2.0 use kotlinx.serialization 0.14.x\n\nkbson after 0.2.2 use kotlinx.serialization 0.20.0 and kotlin 1.3.71\n\nkbson after 0.4.0 use kotlinx.serialization \"1.0-M1-1.4.0-rc\" and kotlin 1.4.0-rc\n\nkbson after 0.4.1 use kotlinx.serialization \"1.0.0\" and kotlin 1.4.10\n\nkbson after 0.4.3 use kotlinx.serialization \"1.0.0\" and kotlin 1.4.20\n\nkbson after 0.4.5 use kotlinx.serialization \"1.3.3\" and kotlin 1.6.21\n\nkbson after 0.4.6 use kotlinx.serialization \"1.3.3\" and kotlin 1.6.21\n\nkbson after 0.5.0 use kotlinx.serialization \"1.4.1\" and kotlin 1.7.20\n\n\n# Contributing to kbson\nPull requests and bug reports are always welcome!\n\nTo run the tests: ./gradlew check\n\n# Reference links\n- http://litote.org/kmongo/ | https://github.com/Litote/kmongo\n- https://github.com/Kotlin/kotlinx.serialization\n- https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md\n- https://mongodb.github.io/mongo-java-driver/\n- Special thanks to: https://github.com/charleskorn/kaml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjershell%2Fkbson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjershell%2Fkbson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjershell%2Fkbson/lists"}