🔍

首页Home › 开发工具Developer Tools

λ JSON 转 Haskell 数据类型(Aeson)JSON to Haskell (Aeson)

根据 JSON 生成 Haskell 记录类型和 Aeson 的 FromJSON / ToJSON 实例:Text、Int、Double、[a]、Maybe a 等类型自动推断,字段名加类型前缀避免冲突。Generate Haskell record types with Aeson FromJSON / ToJSON instances from JSON: Text, Int, Double, [a] and Maybe a are inferred, and field names are prefixed with the type name to avoid clashes.

使用说明与常见问题How-to & FAQ

「JSON 转 Haskell 数据类型(Aeson)」是什么?What is the JSON to Haskell (Aeson) tool?

根据 JSON 生成 Haskell 记录类型和 Aeson 的 FromJSON / ToJSON 实例:Text、Int、Double、[a]、Maybe a 等类型自动推断,字段名加类型前缀避免冲突。Generate Haskell record types with Aeson FromJSON / ToJSON instances from JSON: Text, Int, Double, [a] and Maybe a are inferred, and field names are prefixed with the type name to avoid clashes.

如何使用「JSON 转 Haskell 数据类型(Aeson)」?How do I use the JSON to Haskell (Aeson)?

粘贴 JSON 并填写模块名(根类型名),下方生成完整的 Haskell 模块,需要依赖 aeson 和 text 包。用 decode 或 eitherDecode 解析 JSON。Paste JSON and set the module (root type) name to get a full Haskell module that depends on the aeson and text packages. Parse with decode or eitherDecode.

为什么字段名前面都带了类型名?Why are field names prefixed?

Haskell 的记录字段会生成同名的顶层函数,不同类型里有同名字段(如两个类型都有 id)会冲突。加上类型前缀(rootId、orderId)是最通用的解决办法,JSON 键名保持不变。Haskell record fields become top-level functions, so the same field name in two types (e.g. id) would clash. Prefixing with the type name (rootId, orderId) is the most portable fix; the JSON keys stay unchanged.

.: 和 .:? 有什么区别?.: vs .:?

.: 要求键必须存在,否则解析失败;.:? 在键不存在或值为 null 时返回 Nothing。工具会对样本中可能缺失或为 null 的字段使用 .:? 和 Maybe 类型。.: requires the key and fails otherwise; .:? returns Nothing when the key is missing or null. The tool uses .:? and Maybe for fields that may be missing or null in the sample.

「JSON 转 Haskell 数据类型(Aeson)」免费吗?数据会上传吗?Is the JSON to Haskell (Aeson) free? Is my data uploaded?

「JSON 转 Haskell 数据类型(Aeson)」完全免费,无需注册或安装,手机和电脑都能用;所有处理都在你的浏览器本地完成,输入的内容和文件不会上传到服务器。The JSON to Haskell (Aeson) is completely free with no sign-up or install and works on phones and desktops; everything runs locally in your browser and nothing you enter is uploaded.

相关工具Related tools

🟦 JSON 转 TypeScriptJSON to TypeScript Interface🐹 JSON 转 Go 结构体JSON to Go Struct☕ JSON 转 Java 实体类JSON to Java POJO💠 JSON 转 C# 实体类JSON to C# Class🐍 JSON 转 Python 字典/列表JSON to Python Dict Converter🟣 JSON 转 Kotlin 数据类JSON to Kotlin Data Class🕊️ JSON 转 Swift CodableJSON to Swift Codable🦀 JSON 转 Rust 结构体(serde)JSON to Rust Struct (serde)📐 JSON Schema 生成器JSON Schema Generator🧾 JSON 格式化校验JSON Formatter & Validator

← 全部工具All tools