{"id":21206235,"url":"https://github.com/rtmigo/json2kt_kt","last_synced_at":"2026-05-07T12:31:41.840Z","repository":{"id":138532856,"uuid":"465447143","full_name":"rtmigo/json2kt_kt","owner":"rtmigo","description":"Kotlin/JVM command line utility converting JSON to Kotlin","archived":false,"fork":false,"pushed_at":"2022-03-02T19:55:12.000Z","size":69,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"staging","last_synced_at":"2025-01-21T15:32:19.307Z","etag":null,"topics":["code-generation","conversion","json","jvm"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/rtmigo.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":"2022-03-02T19:44:57.000Z","updated_at":"2024-03-13T23:43:41.000Z","dependencies_parsed_at":"2023-07-06T16:01:32.405Z","dependency_job_id":null,"html_url":"https://github.com/rtmigo/json2kt_kt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Fjson2kt_kt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Fjson2kt_kt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Fjson2kt_kt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Fjson2kt_kt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtmigo","download_url":"https://codeload.github.com/rtmigo/json2kt_kt/tar.gz/refs/heads/staging","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658274,"owners_count":20326467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["code-generation","conversion","json","jvm"],"created_at":"2024-11-20T20:54:56.840Z","updated_at":"2026-05-07T12:31:36.820Z","avatar_url":"https://github.com/rtmigo.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [json2kt](https://github.com/rtmigo/json2kt_kt)\n\nCommand line utility converting JSON to Kotlin declarations.\n\nInput:\n\n```json\n[ {\"season\": \"Winter\", \"days\": 90.25},\n  {\"season\": \"Spring\", \"days\": 92},\n  {\"season\": \"Summer\", \"days\": 92},\n  {\"season\": \"Autumn\", \"days\": 91} ]\n```\n\nOutput:\n\n```kotlin\nlistOf(\n    mapOf(\"season\" to \"Winter\", \"days\" to 90.25), \n    mapOf(\"season\" to \"Spring\", \"days\" to 92), \n    mapOf(\"season\" to \"Summer\", \"days\" to 92),\n    mapOf(\"season\" to \"Autumn\", \"days\" to 91)\n)\n```\n\nActually the result will be one line. Here it is formatted for ease of reading.\n\n# Install\n\nJust download `json2kt.jar` attached to the [latest release](https://github.com/rtmigo/json2kt_kt/releases).\n\n# Use\n\n## From JSON to Kotlin\n\nRun:\n\n```\njava -jar json2kt.jar\n```\n\nEnter the input code when prompted. Add `;` after the code to indicate there will be\nno more input.\n\n```json\n[ {\"season\": \"Winter\", \"days\": 90.25},\n  {\"season\": \"Spring\", \"days\": 92},\n  {\"season\": \"Summer\", \"days\": 92},\n  {\"season\": \"Autumn\", \"days\": 91} ]\n;\n```\n\nGet output:\n\n```kotlin\nlistOf(\n    mapOf(\"season\" to \"Winter\", \"days\" to 90.25),\n    mapOf(\"season\" to \"Spring\", \"days\" to 92),\n    mapOf(\"season\" to \"Summer\", \"days\" to 92),\n    mapOf(\"season\" to \"Autumn\", \"days\" to 91)\n)\n```\n\n## From JSON-like text to Kotlin\n\nLet's say you run the following Kotlin code:\n\n```kotlin\nval data = listOf(\n    mapOf(\"season\" to \"Winter\", \"days\" to 90.25),\n    mapOf(\"season\" to \"Spring\", \"days\" to 92),\n    mapOf(\"season\" to \"Summer\", \"days\" to 92),\n    mapOf(\"season\" to \"Autumn\", \"days\" to 91)\n)\n\nprintln(data)\n```\n\nIt will print out the following:\n\n```\n[ {season=Winter, days=90.25}, \n  {season=Spring, days=92},\n  {season=Summer, days=92},\n  {season=Autumn, days=91} ]\n```\n\nSuch a string is not JSON. And it cannot even be unambiguously interpreted. \n\n`json2kt` will accept such a string as input, and recognize it if possible.\n\n\n## Read/write files \n\nThe utility has no special arguments for working with files. But it works well with UNIX redirects.\n\nGetting input from file:\n\n```\njava -jar json2kt.jar \u003c file.json\n```\n\nWriting output to file:\n\n```\njava -jar json2kt.jar \u003e output.kt\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtmigo%2Fjson2kt_kt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtmigo%2Fjson2kt_kt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtmigo%2Fjson2kt_kt/lists"}