{"id":51849212,"url":"https://github.com/dingkui/dlz-kit","last_synced_at":"2026-07-23T17:01:28.704Z","repository":{"id":262617429,"uuid":"682447355","full_name":"dingkui/dlz-kit","owner":"dingkui","description":"像JavaScript一样在Java中“丝滑”操作JSON","archived":false,"fork":false,"pushed_at":"2026-07-23T14:07:41.000Z","size":6599,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-07-23T14:07:57.356Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dingkui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-08-24T07:29:34.000Z","updated_at":"2026-07-23T12:18:13.000Z","dependencies_parsed_at":"2024-11-13T11:49:59.881Z","dependency_job_id":null,"html_url":"https://github.com/dingkui/dlz-kit","commit_stats":null,"previous_names":["dingkui/dlz.framwork","dingkui/dlz.framework","dingkui/dlz.kit","dingkui/dlz-kit"],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/dingkui/dlz-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dingkui%2Fdlz-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dingkui%2Fdlz-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dingkui%2Fdlz-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dingkui%2Fdlz-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dingkui","download_url":"https://codeload.github.com/dingkui/dlz-kit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dingkui%2Fdlz-kit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35809505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-23T02:00:06.683Z","response_time":57,"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":[],"created_at":"2026-07-23T17:01:28.005Z","updated_at":"2026-07-23T17:01:28.688Z","avatar_url":"https://github.com/dingkui.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSONMap — Java 嵌套数据操作，一行到位\n\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![JDK](https://img.shields.io/badge/JDK-8%20%7C%2011%20%7C%2017%20%7C%2021-green.svg)]()\n[![Size](https://img.shields.io/badge/Size-~100KB-brightgreen.svg)]()\n[![Maven](https://img.shields.io/badge/Maven-top.dlzio:dlz-kit-orange)](https://github.com/dingkui/dlz-kit)\n\n```java\n// 以前：10 行判空 + 强转，还可能 NPE\n// 现在：1 行，没有中间对象，不会 NPE\nString city = new JSONMap(response).getStr(\"data.user.profile.addresses[0].city\");\n```\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003etop.dlzio\u003c/groupId\u003e\n    \u003cartifactId\u003edlz-kit\u003c/artifactId\u003e\n    \u003cversion\u003e6.6.6\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n---\n\n## 30 秒上手\n\n```java\n// 解析 JSON\nJSONMap data = new JSONMap(\"{\\\"user\\\":{\\\"name\\\":\\\"张三\\\",\\\"age\\\":\\\"25\\\"}}\");\n\n// 深层取值——路径不存在返回 null，不会 NPE\nString name = data.getStr(\"user.name\");          // \"张三\"\nInteger age = data.getInt(\"user.age\");            // 25（自动从字符串转）\nList\u003cInteger\u003e ids = data.getList(\"user.ids\", Integer.class); // 空返回空列表\n\n// 构建嵌套结构——中间层级自动创建\nJSONMap result = new JSONMap()\n    .set(\"meta.version\", \"1.0\")\n    .set(\"data.user.name\", \"张三\");\n// → {\"meta\":{\"version\":\"1.0\"},\"data\":{\"user\":{\"name\":\"张三\"}}}\n```\n\n---\n\n## 三个核心能力\n\n### 深层路径取值\n\n不用中间变量、不用逐层判空、不担心 NPE。\n\n```java\n// 任意层级为 null → 返回 null\nString v = data.getStr(\"a.b.c.d.e.f\");  // null，没有异常\n\n// 支持数组索引和负索引\nString last = data.getStr(\"tags[-1]\");  // 倒数第一个\nLong time = data.getLong(\"history.logs[-2].timestamp\");\n\n// 类型自动转换\nBigDecimal amount = data.getBigDecimal(\"order.payment.total\");  // \"99.9\" → 99.9\n```\n\n### 动态结构构建\n\n```java\n// 对比：传统方式需要逐层 new HashMap\n// JSONMap：路径即结构\nJSONMap req = new JSONMap()\n    .set(\"header.traceId\", UUID.randomUUID().toString())\n    .set(\"header.source\", \"API\")\n    .set(\"body.user.name\", \"张三\")\n    .set(\"body.user.profile.city\", \"上海\");\n```\n\n### 类型转换（ValUtil）\n\n数据来源（前端表单、数据库、第三方 API）的类型不可控时，不用到处 try-catch。\n\n```java\nInteger age = ValUtil.toInt(params.get(\"age\"));              // 不抛异常，返回 null 或正确值\nInteger safe = ValUtil.toInt(params.get(\"age\"), 0);          // 带默认值\nList\u003cInteger\u003e ids = ValUtil.toList(params.get(\"ids\"), Integer.class); // \"1,2,3\" → [1,2,3]\n```\n\n---\n\n## 不是替代 Jackson，是 Jackson 之后的那层\n\n| 层 | 做的事 | 工具 |\n|----|--------|------|\n| 序列化层 | JSON 字符串 ↔ Java 对象 | Jackson / Gson |\n| **操作层** | 拿到对象后怎么读写、构建、转换 | **JSONMap / ValUtil** |\n\nJackson 负责搬运，JSONMap 负责加工。两者互补，不冲突。\n\n---\n\n## AI 辅助开发\n\nJSONMap 的 API 模式固定、参数少、无重载歧义，AI 模型容易生成正确代码。\n\n```java\n// AI 生成结果示例（来自真实 prompt 测试）\nJSONMap resp = new JSONMap(callbackBody);\nString orderId = resp.getStr(\"data.order.orderId\");\nInteger amount = resp.getInt(\"data.order.amount\");\n```\n\n在 Cursor / Copilot 中将 `docs/AI-速读指南.md` 添加到上下文即可。\n\n---\n\n## 20 年积累，不止是一个工具类\n\n这套代码从 2006 年开始积累，经过上百个内部项目的验证。核心设计原则\"有界宽容\"——对结构缺失宽容，对数据错误不放过——来自三次生产事故的教训。它不是一个月写出来的 demo，是 20 年修修补补沉淀下来的实用工具集。\n\n---\n\n## 同类工具定位\n\n| 库 | 擅长 | 和 JSONMap 的关系 |\n|----|------|-------------------|\n| Jackson | JSON ↔ 对象 | 互补。Jackson 负责序列化，JSONMap 负责操作 |\n| JSONPath | 查询语法 | 只读不写。JSONMap 能读能写能转 Bean |\n| Hutool | 全功能工具集 | 定位不同。JSONMap 更聚焦动态数据和嵌套操作 |\n\n---\n\n## 项目状态\n\n- **JDK**：8 / 11 / 17 / 21\n- **依赖**：jackson-databind（你的项目大概率已有）\n- **体积**：~100KB\n- **测试**：完整测试用例覆盖\n\n## 文档\n\n- [快速上手](docs/第01章-快速入门/1.2-五分钟上手.md)\n- [JSONMap 完整指南](docs/第02章-核心功能/2.1-JSONMap完整指南.md)\n- [ValUtil 类型转换](docs/第03章-工具类库/3.1-ValUtil-类型转换.md)\n- [@SetValue 注解映射](docs/第04章-高级特性/4.1-SetValue注解映射.md)\n- [有界宽容原则](docs/第04章-高级特性/4.4-有界宽容原则.md)\n- [性能测试报告](docs/第07章-附录/7.1-性能测试报告.md)\n- [AI 速读指南](docs/AI-速读指南.md)（给 AI 模型看的快速参考）\n\n---\n\n如果觉得有用，点个 ⭐ 让更多人看到。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdingkui%2Fdlz-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdingkui%2Fdlz-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdingkui%2Fdlz-kit/lists"}