Formateurs & Code
JSON en Codable Swift
Swift Codable structs with CodingKeys when needed.
Note de la rédaction
Understanding · Codable, and the small print.
Ce chapitre approfondi n'est actuellement disponible qu'en anglais. L'outil de conversion ci-dessus fonctionne dans votre langue ; le long article explicatif n'a pas encore été traduit.
Questions fréquentes
Quick answers.
›Does this tool support snake_case to camelCase conversion?
Yes. If the input contains snake_case keys, the tool generates camelCase properties and an internal `CodingKeys` enum to map them correctly.
›What happens with nested objects in the JSON?
Nested objects are extracted into their own individual structs. The tool creates a clean hierarchy that reflects the structure of your JSON payload.
›Is my API schema sent to your servers?
No. The parsing logic is executed entirely on your local machine using JavaScript. Your JSON and the resulting Swift code are never transmitted to our servers.
›How does it handle optional values or nulls?
Properties are marked as Optional if a value is null in the sample JSON. For more robust models, ensure your sample JSON represents the maximum possible data structure.
Les internautes recherchent aussi
Outils similaires
More in this room.
- JSON en interface TypeScriptDéduisez les types à partir d'un exemple JSON et émettez des interfaces TS.
- JSON en classe C#Générez des classes POCO à partir d'un exemple JSON.
- JSON en POJO JavaÉmettez un POJO Java à partir d'un exemple JSON.
- JSON en dataclasse PythonDataclasses typées (avec Pydantic optionnel) à partir de JSON.
- JSON en struct GoStructs Go idiomatiques avec des tags `json:`.
- JSON en classe de données KotlinClasses de données concises pour tout exemple JSON.