Back to blog

Little Big Detail #1: Perfect Property Names

This first Little Big Detail is part of how quicktype turns JSON property names into nice property names in your preferred target language.

Little Big Details are the subtle details that quicktype takes care of when turning your data into beautiful, readable code.

The Problem

JSON property names come in all shapes and sizes:

{
  "user_name": "alice",
  "firstName": "Alice",
  "LAST-NAME": "Smith",
  "EmailAddress": "alice@example.com"
}

Different languages have different naming conventions:

  • Swift uses camelCase for properties
  • Python uses snake_case
  • C# uses PascalCase

The Solution

quicktype intelligently converts property names to match each language's conventions while preserving the ability to serialize/deserialize correctly.

For Swift, the above JSON becomes:

struct User: Codable {
    let userName: String
    let firstName: String
    let lastName: String
    let emailAddress: String
    
    enum CodingKeys: String, CodingKey {
        case userName = "user_name"
        case firstName
        case lastName = "LAST-NAME"
        case emailAddress = "EmailAddress"
    }
}

How It Works

quicktype:

  1. Detects the naming style of each property (snake_case, camelCase, kebab-case, etc.)
  2. Splits the name into words
  3. Reconstructs the name in the target language's convention
  4. Generates mapping code when the JSON name differs from the property name

This ensures your code feels native while maintaining perfect JSON compatibility.