AppleScript名:JSONデータからのしぼりこみ |
— Created 2016-11-16 by Takaaki Naganoya — 2016 Piyomaru Software use AppleScript version "2.4" — Yosemite (10.10) or later use framework "Foundation" use scripting additions set theJSON to "{\"timeblocksDefs\": { \"normal\": { \"morning\": \"06-09\", \"day\": \"09-18\", \"primetime\": \"18-22\", \"nighttime\": \"22-06\" }, \"lateprime\": { \"morning\": \"06-09\", \"day\": \"09-19\", \"primetime\": \"19-23\", \"nighttime\": \"23-06\" } }} " set theDict to my convertJSONToDictionary:theJSON set theResult to (theDict’s valueForKeyPath:"timeblocksDefs.lateprime") — convert to AS equivalent set theResult to item 1 of ((current application’s NSArray’s arrayWithObject:theResult) as list) on convertJSONToDictionary:jsonString set aString to current application’s NSString’s stringWithString:jsonString set theData to aString’s dataUsingEncoding:(current application’s NSUTF8StringEncoding) set {theDict, theError} to current application’s NSJSONSerialization’s JSONObjectWithData:theData options:0 |error|:(reference) if theDict is missing value then error (theError’s localizedDescription() as text) number -10000 return theDict end convertJSONToDictionary: |
More from my site
(Visited 20 times, 1 visits today)