AppleScript名:ASOCでjson文字列をrecordに |
— Created 2015-07-20 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set jsonText to "{\"abc\":\"test\",\"bcd\":\"test2\",\"cde\":\"test3\"}" set jsonString to current application’s NSString’s stringWithString:jsonText –> (NSString) "{"abc":"test","bcd":"test2","cde":"test3"}" set jsonData to jsonString’s dataUsingEncoding:(current application’s NSUTF8StringEncoding) –> (NSData) <7b226162 63223a22 74657374 222c2262 6364223a 22746573 7432222c 22636465 223a2274 65737433 227d> set aJsonDict to current application’s NSJSONSerialization’s JSONObjectWithData:jsonData options:0 |error|:(missing value) –> (NSDictionary) {abc:"test", bcd:"test2", cde:"test3"} set aRec to aJsonDict as record –> {abc:"test", bcd:"test2", cde:"test3"} |
More from my site
(Visited 182 times, 1 visits today)