# json_repair_java **Repository Path**: SuperWindcloud/json_repair_java ## Basic Information - **Project Name**: json_repair_java - **Description**: 一个用于修复 LLM 的 JSON 字符串输出的小型Java 库 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-01-18 - **Last Updated**: 2025-01-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LLM JSON auto repair 一个用于修复 LLM 的 JSON 字符串输出的小型库。它修复了 LLM JSON 输出的大多数常见问题,例如: * 删除```json```代码块 * 添加缺少的逗号 * 尽可能添加缺失的双引号 * 将单引号替换为双引号 * 转义特殊字符 \t \n * 以及许多其他常见问题 ## Usage ## Add dependency ```xml com.cdpn llm-json-auto-repair 1.0.1 ``` Your Java code ```java import com.cdpn.jsonautorepair.JSONAutoRepairer; JSONAutoRepairer jsonAutoRepairer = new JSONAutoRepairer(); String originalJSON = """ ```json { "name": "Alice", "sex": "female" "address": "123 Andrew Street, ward 3, district 10" } ``` """; String fixedJSON = jsonAutoRepairer.repair(originalJSON); ``` It will automatically fix the JSON string and return the fixed JSON string if possible. In case the JSON string cannot be fixed, it returns null