recordをJSON文字列に変換するAppleScriptです。
AppleScript名:recordをJSON文字列に.scpt |
— Created 2015-07-20 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set aRec to {abc:"test", bcd:"test2", cde:"test3"} set aJson to convRecToJson(aRec) of me as string –> "{"abc":"test","bcd":"test2","cde":"test3"}" on convRecToJson(aRec) set aDict to current application’s NSDictionary’s dictionaryWithDictionary:aRec set jsonData to current application’s NSJSONSerialization’s dataWithJSONObject:aDict options:(0 as integer) |error|:(missing value) –0 is NSJSONWritingPrettyPrinted set resString to current application’s NSString’s alloc()’s initWithData:jsonData encoding:(current application’s NSUTF8StringEncoding) return resString end convRecToJson |
More from my site
(Visited 34 times, 1 visits today)