AppleScript名:Listのrecordをエンコーディングしてplist文字列にする |
— Created 2016-10-30 by Takaaki Naganoya — 2016 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" –http://piyocast.com/as/archives/4295 set aList to {{theName:"サウンドトラック", numberOfTimes:1721}, {theName:"ロック", numberOfTimes:942}} –2D Arrayをplistの文字列にエンコードする set anArray to current application’s NSArray’s arrayWithObject:aList set pListData to current application’s NSPropertyListSerialization’s dataFromPropertyList:anArray |format|:(current application’s NSPropertyListXMLFormat_v1_0) errorDescription:(missing value) set bStr to (current application’s NSString’s alloc()’s initWithData:pListData encoding:(current application’s NSUTF8StringEncoding)) as string (* –> "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> <plist version=\"1.0\"> <array> <array> <dict> <key>numberOfTimes</key> <integer>1721</integer> <key>theName</key> <string>サウンドトラック</string> </dict> <dict> <key>numberOfTimes</key> <integer>942</integer> <key>theName</key> <string>ロック</string> </dict> </array> </array> </plist> " *) |
More from my site
(Visited 18 times, 1 visits today)