In this post I'll show you how to customize quicktype's output.
Suppose we're building a mobile game in C# that the player can pick up on their Android phone and continue on iOS. We need to save game state to JSON.
Basic Generation
Given our game state JSON:
{
"player_name": "Hero123",
"level": 42,
"xp": 15000,
"inventory": ["sword", "shield", "potion"],
"position": { "x": 100.5, "y": 200.3 }
}
Basic quicktype command:
quicktype game-state.json -l csharp -o GameState.cs
Customization Options
Namespace
quicktype game-state.json -l csharp \
--namespace MyGame.Models \
-o GameState.cs
Property Attributes
quicktype game-state.json -l csharp \
--features attributes-only \
-o GameState.cs
This generates POCOs with JsonProperty attributes but without helper methods.
Array Type
Use List
quicktype game-state.json -l csharp \
--array-type list \
-o GameState.cs
Access Modifiers
quicktype game-state.json -l csharp \
--access-modifiers internal \
-o GameState.cs
Language-Specific Options
Each language has unique options. View them with:
quicktype --lang csharp --help
Common options include:
- Swift:
--struct-or-class,--access-level - TypeScript:
--just-types,--runtime-typecheck - Java:
--package,--lombok - Go:
--package,--just-types-and-package
Configuration Files
Save your options in a quicktype.json config file:
{
"lang": "csharp",
"namespace": "MyGame.Models",
"features": "complete",
"array-type": "list"
}
Then run:
quicktype --config quicktype.json game-state.json -o GameState.cs