{"id":49284796,"url":"https://github.com/ktav-lang/java","last_synced_at":"2026-04-25T21:01:09.680Z","repository":{"id":353613915,"uuid":"1220177334","full_name":"ktav-lang/java","owner":"ktav-lang","description":"Java bindings for Ktav — a plain configuration format with three rules, zero indentation, and zero quoting. JNA over the reference Rust crate — no JNI for consumers, prebuilt binaries for Linux/macOS/Windows.","archived":false,"fork":false,"pushed_at":"2026-04-24T16:29:43.000Z","size":91,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-24T18:24:10.348Z","etag":null,"topics":["bindings","config","config-format","configuration","java","jna","ktav","parser","rust","serializer"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/ktav-lang.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-24T16:17:04.000Z","updated_at":"2026-04-24T16:29:28.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ktav-lang/java","commit_stats":null,"previous_names":["ktav-lang/java"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ktav-lang/java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktav-lang%2Fjava","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktav-lang%2Fjava/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktav-lang%2Fjava/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktav-lang%2Fjava/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktav-lang","download_url":"https://codeload.github.com/ktav-lang/java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktav-lang%2Fjava/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32276628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: 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":["bindings","config","config-format","configuration","java","jna","ktav","parser","rust","serializer"],"created_at":"2026-04-25T21:01:08.405Z","updated_at":"2026-04-25T21:01:09.669Z","avatar_url":"https://github.com/ktav-lang.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ktav — Java bindings\n\n**Languages:** **English** · [Русский](README.ru.md) · [简体中文](README.zh.md)\n\nJava bindings for the [Ktav configuration format](https://github.com/ktav-lang/spec).\nThin wrapper around the reference Rust parser, loaded at runtime through\n[JNA](https://github.com/java-native-access/jna) — so **no JNI build on\nthe consumer side**, plain Gradle/Maven just works.\n\nRequires **JDK 17+**. Distributed via GitHub Releases for now\n(Maven Central publication is planned).\n\n## Quick start\n\n`build.gradle.kts`:\n\n```kotlin\nrepositories {\n    mavenCentral()\n    // while we're not yet on Maven Central, consume the JAR from\n    // the GitHub Release — see the README for a worked example.\n}\n\ndependencies {\n    implementation(\"io.github.ktav-lang:ktav:0.1.0\")\n    implementation(\"net.java.dev.jna:jna:5.15.0\")\n}\n```\n\n### Parse — pull typed fields out of a document\n\n```java\nimport lang.ktav.Ktav;\nimport lang.ktav.Value;\n\nString src = \"\"\"\n        service: web\n        port:i 8080\n        ratio:f 0.75\n        tls: true\n        tags: [\n            prod\n            eu-west-1\n        ]\n        db.host: primary.internal\n        db.timeout:i 30\n        \"\"\";\n\nValue.Obj top = (Value.Obj) Ktav.loads(src);\n\nString  service = ((Value.Str)  top.entries().get(\"service\")).value();\nlong    port    = ((Value.Int)  top.entries().get(\"port\")).toLong();\ndouble  ratio   = ((Value.Flt)  top.entries().get(\"ratio\")).toDouble();\nboolean tls     = ((Value.Bool) top.entries().get(\"tls\")).value();\n\nValue.Obj db    = (Value.Obj) top.entries().get(\"db\");\nString dbHost   = ((Value.Str) db.entries().get(\"host\")).value();\nlong   dbTimeout = ((Value.Int) db.entries().get(\"timeout\")).toLong();\n```\n\n### Walk — dispatch on the sealed `Value` hierarchy\n\n```java\nfor (var e : top.entries().entrySet()) {\n    if      (e.getValue() instanceof Value.Bool b) System.out.println(e.getKey() + \" is bool=\" + b.value());\n    else if (e.getValue() instanceof Value.Int  i) System.out.println(e.getKey() + \" is int=\" + i.text());\n    else if (e.getValue() instanceof Value.Arr  a) System.out.println(e.getKey() + \" is array(\" + a.items().size() + \")\");\n    // ...Null / Flt / Str / Obj\n}\n```\n\nOn JDK 21+ this becomes a `switch` expression on the sealed type pattern.\n\n### Build \u0026 render — construct a document in code\n\n```java\nimport java.util.LinkedHashMap;\nimport java.util.List;\n\nLinkedHashMap\u003cString, Value\u003e upstream = new LinkedHashMap\u003c\u003e();\nupstream.put(\"host\", new Value.Str(\"a.example\"));\nupstream.put(\"port\", Value.Int.of(1080));\n\nLinkedHashMap\u003cString, Value\u003e doc = new LinkedHashMap\u003c\u003e();\ndoc.put(\"name\",      new Value.Str(\"frontend\"));\ndoc.put(\"port\",      Value.Int.of(8443));\ndoc.put(\"tls\",       Value.Bool.TRUE);\ndoc.put(\"ratio\",     Value.Flt.of(0.95));\ndoc.put(\"upstreams\", new Value.Arr(List.of(new Value.Obj(upstream))));\ndoc.put(\"notes\",     Value.Null.NULL);\n\nString text = Ktav.dumps(new Value.Obj(doc));\n// name: frontend\n// port:i 8443\n// tls: true\n// ratio:f 0.95\n// upstreams: [\n//     {\n//         host: a.example\n//         port:i 1080\n//     }\n// ]\n// notes: null\n```\n\nA complete runnable version lives in [`examples/basic`](examples/basic/src/main/java/examples/Basic.java).\n\n## API\n\n| Function | Purpose |\n| --- | --- |\n| `Ktav.loads(String) -\u003e Value` | Parse a Ktav document into the {@link Value} tree. |\n| `Ktav.dumps(Value) -\u003e String` | Render a `Value` back as Ktav text. Top-level must be an `Obj`. |\n| `Ktav.nativeVersion() -\u003e String` | Version string reported by the loaded `ktav_cabi`. |\n\n`KtavException` is thrown on any parse / render failure; the message is\nthe UTF-8 string produced by the native parser.\n\n## Type mapping\n\nMirrors the Rust crate's `Value` enum — one variant per Ktav primitive,\nno lossy coercions:\n\n| Ktav             | `Value` variant                                         |\n| ---------------- | ------------------------------------------------------- |\n| `null`           | `Value.Null.NULL`                                       |\n| `true` / `false` | `Value.Bool`                                            |\n| `:i \u003cdigits\u003e`    | `Value.Int` (text form — arbitrary precision, `toBigInteger()` / `toLong()`) |\n| `:f \u003cnumber\u003e`    | `Value.Flt` (text form — exact round-trip, `toDouble()`) |\n| bare scalar      | `Value.Str`                                             |\n| `[ ... ]`        | `Value.Arr` (`List\u003cValue\u003e`)                             |\n| `{ ... }`        | `Value.Obj` (`LinkedHashMap\u003cString, Value\u003e`, insertion order preserved) |\n\nTyped integers and floats are held as **text** so arbitrary precision\n(digits beyond `long`) and exact decimal round-trip are preserved byte\nfor byte across parse/render cycles.\n\n## How the native library is resolved\n\nAt first call, the Java library resolves `ktav_cabi` in this order:\n\n1. **`$KTAV_LIB_PATH`** — absolute path to a local build. Most useful\n   for development and air-gapped CI.\n2. **User cache** — `\u003cuserCache\u003e/ktav-java/v\u003cversion\u003e/…`, downloaded on\n   a previous call.\n3. **GitHub Release download** — the matching asset is fetched once\n   from `github.com/ktav-lang/java/releases/download/v\u003cversion\u003e/\u003cname\u003e`\n   and cached under (2). Requires network on first call after install.\n\n`\u003cuserCache\u003e` is `%LOCALAPPDATA%` on Windows, `~/Library/Caches` on\nmacOS, `$XDG_CACHE_HOME` or `~/.cache` on Linux.\n\n## Runtime support\n\n- JDK 17+ (sealed interfaces).\n- Prebuilt binaries for: `linux/amd64`, `linux/arm64`, `darwin/amd64`,\n  `darwin/arm64`, `windows/amd64`, `windows/arm64`.\n- Linux distros must use glibc 2.17+ (Rust's default target). Alpine\n  (musl) support is planned.\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n\nKtav spec: [ktav-lang/spec](https://github.com/ktav-lang/spec).\nReference Rust crate: [ktav-lang/rust](https://github.com/ktav-lang/rust).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktav-lang%2Fjava","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktav-lang%2Fjava","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktav-lang%2Fjava/lists"}