`plutil` が json 形式にコンバートしてくれないっ、てゆのは

やりたかったこと。;

plutil -convert json ~/Library/Preferences/com.googlecode.iterm2.plist \
  -o ~/com.googlecode.iterm2.plist.json


plutil コマンド使って plist ファイルを json 形式にコンバートして頂こうとお願いしたのですが、応えはエラー。;

~/Library/Preferences/com.googlecode.iterm2.plist: invalid object in plist for destination format


xml へは出来るのに。;

plutil -convert xml1 ~/Library/Preferences/com.googlecode.iterm2.plist \
  -o ~/com.googlecode.iterm2.plist.json


一応...;

% plutil -lint ~/Library/Preferences/com.googlecode.iterm2.plist
~/Library/Preferences/com.googlecode.iterm2.plist: OK

ですよね。

そんなんなか、目にしたのがこんな記載。;

One complication with this is that some Plist data types cannot be converted by plutil. The workaround I found was to do some pre-processing on the plist before passing it to plutil. Specific to the plist that I’m working with, I had to replace both and tags with .

「あ。」(察し

property
property / The hills are alive*



それは <data> 型と <date> 型のせい

一応、実際に先の Stack Overflow の記載に従って試してみると、確かに上手く変換してくれます。

ではなぜ <data><date> が、なん?、って話。

それは json 側に <data><date> にあたるものがないから

で良いと思います。おそらく。

plutil ではなく、json 側の話、ということのようで。

あくまで plutil 目線でちょっと調べてみると結構ありました。

折角ですので、拓っておきます。;

・The “Date” and “Data” data types are not supported by JSON


JSON format does not allow dates and data, so XML is used by default to write files.


ただし、XMLの要素になってるもののうち、date, dataJSONで対応するものが無いため、 JSON形式に変換するときに問題が起こります。


たぶんJSONに対応していないデータ型がplistに含まれていることが原因。

上の 2 番目の引用にもありますが、xml 形式で扱った方が素直なのかも、ってことなのでしょうか。

はいおしまい。