You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add JSON coercion support for non-JSON plist types
- Add PLIST_OPT_COERCE option to coerce PLIST_DATE, PLIST_DATA, and PLIST_UID to JSON-compatible types (ISO 8601 strings, Base64 strings, and integers)
- Add plist_to_json_with_options() function to allow passing coercion options (and others)
- Update plist_write_to_string() and plist_write_to_stream() to support coercion option
- Add --coerce flag to plistutil for JSON output
- Create plist2json symlink that automatically enables coercion when invoked
Copy file name to clipboardExpand all lines: include/plist/plist.h
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -175,6 +175,11 @@ extern "C"
175
175
PLIST_OPT_PARTIAL_DATA=1 << 1, /**< Print 24 bytes maximum of #PLIST_DATA values. If the data is longer than 24 bytes, the first 16 and last 8 bytes will be written. Only valid for #PLIST_FORMAT_PRINT. */
176
176
PLIST_OPT_NO_NEWLINE=1 << 2, /**< Do not print a final newline character. Only valid for #PLIST_FORMAT_PRINT, #PLIST_FORMAT_LIMD, and #PLIST_FORMAT_PLUTIL. */
177
177
PLIST_OPT_INDENT=1 << 3, /**< Indent each line of output. Currently only #PLIST_FORMAT_PRINT and #PLIST_FORMAT_LIMD are supported. Use #PLIST_OPT_INDENT_BY() macro to specify the level of indentation. */
178
+
PLIST_OPT_COERCE=1 << 4, /**< Coerce plist types that have no native JSON representation into JSON-compatible types.
179
+
#PLIST_DATE is converted to an ISO 8601 date string,
180
+
#PLIST_DATA is converted to a Base64-encoded string, and
181
+
#PLIST_UID is converted to an integer.
182
+
Only valid for #PLIST_FORMAT_JSON. Without this option, these types cause #PLIST_ERR_FORMAT. */
178
183
} plist_write_options_t;
179
184
180
185
/** To be used with #PLIST_OPT_INDENT - encodes the level of indentation for OR'ing it into the #plist_write_options_t bitfield. */
0 commit comments