一、json转plist
plutil -convert xml1 $name.json -o result.plist
二、plist转json
plutil -convert json $name.plist -o result.json
三、json和plist互转脚本可直接保存为command文件执行
cd `dirname $0`
read -p "请选择需要转换的文件" name
if[[ "${name##*.}"x ="json"x ]];then
plutil -convert xml1 $name -o result.plist
fi
if[[ "${name##*.}"x ="plist"x ]];then
plutil -convert json $name -o result.json
#给json文件分行
python3 pythonh.py
fi
echo "执行完毕$name"
#执行完毕之后关闭窗口
osascript -e 'tell aplication "Terminal" to quit' & exit
四、json排序Python文件
import os
import re
fo=open("result.json", "r+")
list=fo.readlines()
fo.truncate(0)
content=list[0]
content=content.replace(",",",\n")
fo.write(content)
fo.close()
网友评论