{"id":22750056,"url":"https://github.com/pwall567/kjson-annotations","last_synced_at":"2026-02-10T03:31:16.436Z","repository":{"id":57735734,"uuid":"395883805","full_name":"pwall567/kjson-annotations","owner":"pwall567","description":"Annotations for Kotlin JSON serialization and deserialization","archived":false,"fork":false,"pushed_at":"2025-02-02T02:21:35.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T12:59:10.287Z","etag":null,"topics":["json","kotlin"],"latest_commit_sha":null,"homepage":"","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/pwall567.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2021-08-14T04:05:37.000Z","updated_at":"2025-02-02T02:21:16.000Z","dependencies_parsed_at":"2025-04-14T13:05:58.582Z","dependency_job_id":null,"html_url":"https://github.com/pwall567/kjson-annotations","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/pwall567/kjson-annotations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwall567","download_url":"https://codeload.github.com/pwall567/kjson-annotations/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwall567%2Fkjson-annotations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29289902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T02:32:08.756Z","status":"ssl_error","status_checked_at":"2026-02-10T02:30:31.937Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["json","kotlin"],"created_at":"2024-12-11T04:11:51.070Z","updated_at":"2026-02-10T03:31:16.405Z","avatar_url":"https://github.com/pwall567.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kjson-annotations\n\n[![Build Status](https://github.com/pwall567/kjson-annotations/actions/workflows/build.yml/badge.svg)](https://github.com/pwall567/kjson-annotations/actions/workflows/build.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Kotlin](https://img.shields.io/static/v1?label=Kotlin\u0026message=v2.0.21\u0026color=7f52ff\u0026logo=kotlin\u0026logoColor=7f52ff)](https://github.com/JetBrains/kotlin/releases/tag/v2.0.21)\n[![Maven Central](https://img.shields.io/maven-central/v/io.kjson/kjson-annotations?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.kjson%22%20AND%20a:%kjson-annotations%22)\n\nAnnotations for Kotlin JSON serialization and deserialization\n\nThese classes provide a means of customizing the operation of the [`kjson`](https://github.com/pwall567/kjson) library.\n\n## Annotations\n\n### `@JSONAllowExtra`\n\nThis annotation is applied to classes to indicate that extra properties in an object are allowed (and are to be ignored)\non deserialization.\nIt has no effect on serialization.\n\nExample:\n```kotlin\n@JSONAllowExtra\ndata class Person(val name: String, val age: Int)\n```\nDeserializing the JSON string `{\"name\":\"Fred Jones\",\"age\":25,\"role\":\"manager\"}` into this class will silently ignore the\n`role` property.\n\n### `@JSONDiscriminator`\n\nThis annotation supplies a \"discriminator\" property name to be used when serializing and deserializing sealed classes.\nAn additional property is added on serialization, and expected on deserialization, identifying the specific sub-class.\n\nThis annotation is applied to the base sealed class, and if it is not used, the `sealedClassDiscriminator` property of\nthe `JSONConfig` will be used, with the default value being \"`class`\".\n\nExample:\n```kotlin\n@JSONDiscriminator(\"type\")\nsealed class Party\n```\nClasses derived from `Party` will have an extra property named `type` indicating the specific sub-class.\n\n### `@JSONIdentifier`\n\nThis annotation supplies the value to be used in the discriminator property to determine the sub-class.\n\nExample:\n```kotlin\n@JSONIdentifier(\"PERSON\")\ndata class Person(val firstName: String, val lastName: String) : Party()\n```\n`Person` objects will have the discriminator property set to \"`PERSON`\" to indicate the sub-class.\n\n### `@JSONIgnore`\n\nThis annotation is applied to properties (including `val` or `var` constructor parameters), and it indicates that the\nrelevant property is to be ignored during serialization and deserialization.\nNote that a constructor parameter annotated with `@JSONIgnore` will need to have a default defined if the constructor is\nto be used in the deserialization of an object with the property missing.\n\nExample:\n```kotlin\nclass Player(val name: String, @JSONIgnore val note: String? = null) {\n    @JSONIgnore\n    var score: Int = 0\n}\n```\nBoth the `note` and `score` properties will be ignored on serialization, and neither will be required (and will be\nignored if present) on deserialization.\n\n### `@JSONIncludeAllProperties`\n\nThis annotation is applied to classes to indicate that all properties in the class are to be included in\nauto-serialization even if `null`.\nIt has no effect on deserialization.\n\nExample:\n```kotlin\n@JSONIncludeAllProperties\ndata class Project(val name: String, val description: String?)\n```\nThe `description` property will be serialized as `\"description\":null` if the property is `null` instead of being\nomitted.\n\n### `@JSONIncludeIfNull`\n\nThis annotation is applied to individual properties (including `val` or `var` constructor parameters) to indicate that\nthe relevant property is to be included in auto-serialization even if `null`.\n\nExample:\n```kotlin\ndata class Project(val name: String, @JSONIncludeIfNull val description: String?)\n```\nThe `description` property will be serialized as `\"description\":null` if the property is `null` instead of being\nomitted.\nThis is similar to the example above but in this case the annotation applies only to the property `description`.\n\n### `@JSONName`\n\nThis annotation is applied to properties and constructor parameters, and it supplies the name to be used in place of the\nproperty or parameter name for auto-serialization and deserialization.\n\nIt takes a single parameter `name` \u0026ndash; the name to be used.\n\nExample:\n```kotlin\ndata class Person(@JSONName(\"surname\") val lastName: String, val firstName: String)\n```\nThe property `lastName` will be serialized and deserialized using the property name `surname`.\n\n## Alternative Annotations\n\nIn many cases, existing code will have annotations for the purposes above already in the code.\nThe `kjson` library can be configured to use these annotations from other libraries \u0026ndash; see the `JSONConfig` class.\n\n## Dependency Specification\n\nThe latest version of the library is 1.5, and it may be obtained from the Maven Central repository.\n\n### Maven\n```xml\n    \u003cdependency\u003e\n      \u003cgroupId\u003eio.kjson\u003c/groupId\u003e\n      \u003cartifactId\u003ekjson-annotations\u003c/artifactId\u003e\n      \u003cversion\u003e1.5\u003c/version\u003e\n    \u003c/dependency\u003e\n```\n### Gradle\n```groovy\n    implementation \"io.kjson:kjson-annotations:1.5\"\n```\n### Gradle (kts)\n```kotlin\n    implementation(\"io.kjson:kjson-annotations:1.5\")\n```\n\nPeter Wall\n\n2025-02-02\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwall567%2Fkjson-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwall567%2Fkjson-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwall567%2Fkjson-annotations/lists"}