JSON数据反扁平化
把点分路径的单层对象还原为嵌套结构。
关于「JSON数据反扁平化」
它属于「JSON 工具」分类:JSON 的格式化、结构变换与各种数据格式互转。
- 把 <code>a.b.c</code> 形式的单层键值还原成<b>多层嵌套对象</b>。
- 同时识别 <code>list[0]</code> 与 <code>list.0</code> 两种数组写法,纯数字键会自动还原为数组。
- 分隔符需要与当初扁平化时使用的保持一致,否则无法正确切分路径。
- 常用于把语言包、配置表等扁平数据还原成程序需要的嵌套结构。
完全免费、无需注册;所有处理都在浏览器本地完成,文件不会上传到任何服务器。
相关关键词:JSON数据反扁平化、JSON 工具、反扁平、unflatten、还原、在线工具、免费
如何使用「JSON数据反扁平化」
- 打开工具:打开「JSON数据反扁平化」页面,无需注册、无需安装任何软件。
- 准备输入:准备好要处理的内容或文件:文本可直接粘贴,文件可拖入页面(本工具属于「JSON 工具」)。
- 填入内容:把内容粘贴进输入框,或把文件拖入页面;也可以点击「示例」先填入样例数据试一下。
- 设置选项并处理:按需调整页面上的选项,然后点击处理 / 转换 / 生成按钮。
- 获取结果:处理完全在浏览器本地完成,结果可直接复制或下载,文件不会上传到任何服务器。
常见问题
- 什么时候会用到?
- 当你从表格、环境变量或 i18n 词条里拿到的是 <code>a.b.c</code> 这种扁平键,而程序需要嵌套对象时,就用这个工具还原。
- 数组是怎么判断的?
- 如果某一层的键全部是连续的纯数字(或写成 <code>[0]</code> 形式),会被还原成数组;只要有一个非数字键,就还原成对象。
- 还原结果和原始数据不一致?
- 最常见的原因是分隔符不匹配,或者原始键名里本身包含分隔符字符。请确认扁平化与反扁平化使用了相同的分隔符设置。
Unflatten JSON (English)
Restore dotted-path objects into nested structures.
Belongs to “JSON Tools”: Format, transform and convert JSON to and from various data formats.
- Restores <code>a.b.c</code> flat keys back into a <b>multi-level nested object</b>.
- Both <code>list[0]</code> and <code>list.0</code> array forms are recognized; purely numeric keys become arrays automatically.
- The separator must match the one used when flattening, otherwise paths cannot be split correctly.
- Commonly used to rebuild flat data like language packs or config tables into the nested structure programs expect.
Free, no sign-up; everything runs locally in your browser and files are never uploaded.
Keywords: Unflatten JSON, JSON Tools, unflatten, restore, online tool, free
How to use it
- Open the tool:Open the “Unflatten JSON” page — no sign-up and nothing to install.
- Prepare the input:Prepare the content or file to process: paste text or drop a file onto the page (this tool belongs to “JSON Tools”).
- Provide the input:Paste your content into the input box or drop a file onto the page; you can also click “Sample” to try example data first.
- Adjust options and run:Adjust the options if needed, then click the process / convert / generate button.
- Get the result:Everything runs locally in your browser; copy or download the result — your files are never uploaded.
FAQ
- When is this useful?
- When you get flat keys like <code>a.b.c</code> from a spreadsheet, env vars or i18n entries but your program needs a nested object, use this to rebuild it.
- How are arrays detected?
- If all keys at a level are consecutive numeric (or written as <code>[0]</code>), they become an array; a single non-numeric key makes it an object.
- Output differs from the original?
- The usual cause is a mismatched separator, or keys that themselves contain the separator. Make sure flatten and unflatten use the same separator setting.
More tools in JSON Tools
- JSON Formatter/Minifier — Beautify, minify, validate and highlight JSON.
- Sort JSON Keys — Recursively sort object keys alphabetically to ease diffing.
- Flatten JSON — Flatten nested structures into a.b.c single-level keys.
- JSON to CSV — Convert an array of objects into a downloadable CSV.
- CSV to JSON — Parse CSV text or files into a JSON array.
- JSON to Excel — Export an array of objects as an .xlsx workbook.
- Excel to JSON — Upload an Excel file and convert sheets to JSON.
- JSON to XML — Convert JSON structures into well-indented XML.
- XML to JSON — Parse an XML document into an equivalent JSON object.
- JSON to YAML — Convert JSON into more readable YAML.
- YAML to JSON — Parse YAML config into standard JSON.
- JSON to SQL — Generate INSERT statements and CREATE TABLE DDL from arrays.
- SQL to JSON — Reverse-engineer JSON data from INSERT statements.
- JSON to Base64 — Convert JSON to and from Base64 with UTF-8 support.
- JSON ⇄ Cookie — Convert between Cookie strings and JSON key-values.
- JSON Diff — Recursively compare two JSON documents, marking add/delete/change.