Converting Plist Boolean Types to JSON
Learn how Apple plist true and false elements map to JSON boolean values. Understand the difference between plist booleans and string representations.
Detailed Explanation
Plist Booleans vs JSON Booleans
Apple plist XML uses self-closing tags <true/> and <false/> to represent boolean values. These map directly to JSON true and false.
Plist Example
<dict>
<key>EnableFeature</key>
<true/>
<key>DebugMode</key>
<false/>
<key>AutoUpdate</key>
<true/>
</dict>
JSON Output
{
"EnableFeature": true,
"DebugMode": false,
"AutoUpdate": true
}
Common Pitfall
Some older plists use the string "YES" or "NO" instead of <true/>/<false/>. These are treated as regular strings in both plist and JSON, not as booleans. The converter preserves this distinction: only <true/> and <false/> become JSON booleans.
Reverse Conversion
When converting JSON back to plist, JavaScript true becomes <true/> and false becomes <false/>. String values like "true" remain as <string>true</string>, maintaining semantic correctness.
Use Case
Useful when reading iOS or macOS feature flags from plist configuration files and converting them to JSON for web dashboards or cross-platform tools that consume JSON.