🔍

首页Home › 开发工具Developer Tools

🍎 JSON 转 Objective-C 模型JSON to Objective-C Model

根据 JSON 生成 Objective-C 模型类的 .h 和 .m:自动推断 NSString、NSInteger、NSArray 等属性类型和 nullable 标注,可选生成 initWithDictionary 解析代码、YYModel 或 MJExtension 映射。Generate Objective-C model classes (.h and .m) from JSON: inferred NSString, NSInteger and NSArray property types with nullability, plus initWithDictionary parsing code or YYModel / MJExtension key mapping.

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

「JSON 转 Objective-C 模型」是什么?What is the JSON to Objective-C Model tool?

根据 JSON 生成 Objective-C 模型类的 .h 和 .m:自动推断 NSString、NSInteger、NSArray 等属性类型和 nullable 标注,可选生成 initWithDictionary 解析代码、YYModel 或 MJExtension 映射。Generate Objective-C model classes (.h and .m) from JSON: inferred NSString, NSInteger and NSArray property types with nullability, plus initWithDictionary parsing code or YYModel / MJExtension key mapping.

如何使用「JSON 转 Objective-C 模型」?How do I use the JSON to Objective-C Model?

粘贴 JSON,填写根类名和类名前缀(如 XY),选择解析方式,下方生成头文件和实现文件代码。snake_case 键名会转成驼峰属性,id、description 等与 NSObject 冲突的名字会自动改名并保留映射。Paste JSON, set the root class name and a class prefix (e.g. XY), choose the parsing style, and the header and implementation appear below. snake_case keys become camelCase properties; names that clash with NSObject, like id or description, are renamed with the mapping kept.

为什么 id 属性被改成了 ID?Why was id renamed to ID?

id 是 Objective-C 的类型关键字,description、hash 等又是 NSObject 已有的方法,直接用作属性名会出错或产生隐患。工具会自动改名,并在映射代码中保留原始 JSON 键名。id is an Objective-C type keyword, and description or hash are existing NSObject methods, so using them as property names breaks or causes subtle bugs. The tool renames them and keeps the original JSON key in the mapping.

数字字段什么时候用 NSNumber?When are numbers NSNumber?

字段在所有样本中都存在且不为 null 时用 NSInteger、double、BOOL;可能缺失或为 null 时用 NSNumber *(nullable),这样能区分「没有值」和 0。Fields present and non-null in every sample use NSInteger, double or BOOL; fields that may be missing or null use nullable NSNumber * so “no value” stays distinct from 0.

「JSON 转 Objective-C 模型」免费吗?数据会上传吗?Is the JSON to Objective-C Model free? Is my data uploaded?

「JSON 转 Objective-C 模型」完全免费,无需注册或安装,手机和电脑都能用;所有处理都在你的浏览器本地完成,输入的内容和文件不会上传到服务器。The JSON to Objective-C Model 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