Json
[bash] JQによるJSONの処理
サンプルコード
行番号 | ソース |
---|---|
001 | #!/bin/bash |
002 | #com.cocolog-nifty.quicktimer.icefloe |
003 | #set -x |
004 | ################################################# |
005 | ###STAT |
006 | STAT_USR=$(/usr/bin/stat -f%Su /dev/console) |
007 | ###EXIFTOOL |
008 | #ここは各デバイス毎の設定を反映させて |
009 | PATH_EXIFTOOL="/Users/${STAT_USR}/bin/exiftool/exiftool" |
010 | #一般的にちちらのになると思います |
011 | # PATH_EXIFTOOL="/usr/local/bin/exiftool/exiftool" |
012 | #サンプルの入力画像ファイル |
013 | PATH_IMAGE_FILE="/System/Library/Desktop Pictures/Solid Colors/Black.png" |
014 | #本処理 |
015 | JSON_RESPONSE=$("$PATH_EXIFTOOL" -json "$PATH_IMAGE_FILE") |
016 | /bin/echo $JSON_RESPONSE |
017 | #JQ処理 |
018 | STR_VALUE=$(/bin/echo "$JSON_RESPONSE" | /usr/bin/jq -r '.[0].ColorType') |
019 | /bin/echo "ColorType: $STR_VALUE" |
020 | STR_VALUE=$(/bin/echo "$JSON_RESPONSE" | /usr/bin/jq -r '.[0].ImageSize') |
021 | /bin/echo "ImageSize: $STR_VALUE" |
022 | STR_VALUE=$(/bin/echo "$JSON_RESPONSE" | /usr/bin/jq -r '.[0].ImageWidth') |
023 | /bin/echo "ImageWidth: $STR_VALUE" |
024 | STR_VALUE=$(/bin/echo "$JSON_RESPONSE" | /usr/bin/jq -r '.[0].ImageHeight') |
025 | /bin/echo "ImageHeight: $STR_VALUE" |
026 | |
027 | #ALLKEYを取得してループで全項目echoする |
028 | /bin/echo "$JSON_RESPONSE" | /usr/bin/jq -r '.[0] | keys[]' | while read ITEM_KEY; do |
029 | STR_VALUE=$(/bin/echo "$JSON_RESPONSE" | /usr/bin/jq -r --arg STR_KEY "$ITEM_KEY" '.[0].[$STR_KEY]') |
030 | /bin/echo "$ITEM_KEY: $STR_VALUE" |
031 | done |
032 | |
033 | exit 0 |
AppleScriptで生成しました |
戻り値 JQによるJSONの処理.bash
サンプルコード
行番号 | ソース |
---|---|
001 | |
002 | [{ "SourceFile": "/System/Library/Desktop Pictures/Solid Colors/Black.png", "ExifToolVersion": 13.26, "FileName": "Black.png", "Directory": "/System/Library/Desktop Pictures/Solid Colors", "FileSize": "390 bytes", "FileModifyDate": "2025:03:27 20:00:33+09:00", "FileAccessDate": "2025:03:27 20:00:33+09:00", "FileInodeChangeDate": "2025:03:27 20:00:33+09:00", "FilePermissions": "-rw-r--r--", "FileType": "PNG", "FileTypeExtension": "png", "MIMEType": "image/png", "ImageWidth": 128, "ImageHeight": 128, "BitDepth": 8, "ColorType": "RGB with Alpha", "Compression": "Deflate/Inflate", "Filter": "Adaptive", "Interlace": "Noninterlaced", "ImageSize": "128x128", "Megapixels": 0.016 }] |
003 | ColorType: RGB with Alpha |
004 | ImageSize: 128x128 |
005 | ImageWidth: 128 |
006 | ImageHeight: 128 |
007 | BitDepth: 8 |
008 | ColorType: RGB with Alpha |
009 | Compression: Deflate/Inflate |
010 | Directory: /System/Library/Desktop Pictures/Solid Colors |
011 | ExifToolVersion: 13.26 |
012 | FileAccessDate: 2025:03:27 20:00:33+09:00 |
013 | FileInodeChangeDate: 2025:03:27 20:00:33+09:00 |
014 | FileModifyDate: 2025:03:27 20:00:33+09:00 |
015 | FileName: Black.png |
016 | FilePermissions: -rw-r--r-- |
017 | FileSize: 390 bytes |
018 | FileType: PNG |
019 | FileTypeExtension: png |
020 | Filter: Adaptive |
021 | ImageHeight: 128 |
022 | ImageSize: 128x128 |
023 | ImageWidth: 128 |
024 | Interlace: Noninterlaced |
025 | MIMEType: image/png |
026 | Megapixels: 0.016 |
027 | SourceFile: /System/Library/Desktop Pictures/Solid Colors/Black.png |
AppleScriptで生成しました |
[天気予報]www.weatherapi.comのAPIを使って天気情報を取得する(JSON)
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | (* |
004 | www.weatherapi.com のAPIで天気取得 |
005 | APIキーが必要です |
006 | com.cocolog-nifty.quicktimer.icefloe*) |
007 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
008 | use AppleScript version "2.8" |
009 | use framework "Foundation" |
010 | use framework "AppKit" |
011 | use framework "UniformTypeIdentifiers" |
012 | use scripting additions |
013 | |
014 | property refMe : a reference to current application |
015 | |
016 | |
017 | set strApiKey to ("XXXXXXXXXXXXXXXXX") as text |
018 | |
019 | #################### |
020 | #設定項目 |
021 | set strURL to "https://api.weatherapi.com/v1/current.json" |
022 | set strSetURL to ("" & strURL & "?key=" & strApiKey & "&q=tokyo&aqi=yes") as text |
023 | |
024 | #################### |
025 | #URL |
026 | set ocidUrlStr to refMe's NSString's stringWithString:(strSetURL) |
027 | set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidUrlStr) |
028 | |
029 | #################### |
030 | #出力用テキスト |
031 | set ocidOutputString to refMe's NSMutableString's alloc()'s init() |
032 | |
033 | #################### |
034 | #NSDATA |
035 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
036 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidURL) options:(ocidOption) |error| :(reference) |
037 | if (item 2 of listResponse) = (missing value) then |
038 | log "initWithContentsOfURL 正常処理" |
039 | set ocidReadJsonData to (item 1 of listResponse) |
040 | else if (item 2 of listResponse) ≠ (missing value) then |
041 | set strErrorNO to (item 2 of listResponse)'s code() as text |
042 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
043 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
044 | return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes |
045 | end if |
046 | #################### |
047 | #JSON ルートがDICT |
048 | set ocidOption to (refMe's NSJSONReadingJSON5Allowed) |
049 | set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadJsonData) options:(ocidOption) |error| :(reference)) |
050 | if (item 2 of listResponse) = (missing value) then |
051 | log "JSONObjectWithData 正常処理" |
052 | set ocidJsonDict to (item 1 of listResponse) |
053 | else if (item 2 of listResponse) ≠ (missing value) then |
054 | set strErrorNO to (item 2 of listResponse)'s code() as text |
055 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
056 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
057 | return "JSONObjectWithData エラーしました" & strErrorNO & strErrorMes |
058 | end if |
059 | log ocidJsonDict's allKeys() as list |
060 | #################### |
061 | #centers |
062 | set ocidCentersDict to ocidJsonDict's objectForKey:("current") |
063 | # |
064 | set ocidText to (ocidCentersDict's valueForKeyPath:("condition.text")) |
065 | set strIcon to (ocidCentersDict's valueForKeyPath:("condition.icon")) as text |
066 | set strIcon to ("https:" & strIcon & "") as text |
067 | ocidOutputString's appendString:("<h1>東京: ") |
068 | ocidOutputString's appendString:(ocidText) |
069 | ocidOutputString's appendString:("</h1>") |
070 | ocidOutputString's appendString:("<p><img src=\"") |
071 | ocidOutputString's appendString:(strIcon) |
072 | ocidOutputString's appendString:("\"></p>") |
073 | # |
074 | set ocidTemp to (ocidCentersDict's valueForKeyPath:("temp_c"))'s stringValue() |
075 | set ocidMb to (ocidCentersDict's valueForKeyPath:("pressure_mb"))'s stringValue() |
076 | ocidOutputString's appendString:("<p>気温: ") |
077 | ocidOutputString's appendString:(ocidTemp) |
078 | ocidOutputString's appendString:("</p>") |
079 | ocidOutputString's appendString:("<p>気圧: ") |
080 | ocidOutputString's appendString:(ocidMb) |
081 | ocidOutputString's appendString:("</p>") |
082 | # |
083 | |
084 | #################### |
085 | #保存先 |
086 | set appFileManager to refMe's NSFileManager's defaultManager() |
087 | set ocidTempDirURL to appFileManager's temporaryDirectory() |
088 | set ocidUUID to refMe's NSUUID's alloc()'s init() |
089 | set ocidUUIDString to ocidUUID's UUIDString |
090 | set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true) |
091 | # |
092 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init() |
093 | ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions) |
094 | set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error| :(reference) |
095 | if (item 1 of listDone) is false then |
096 | set strErrorNO to (item 2 of listDone)'s code() as text |
097 | set strErrorMes to (item 2 of listDone)'s localizedDescription() as text |
098 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
099 | log "createDirectoryAtURL エラーしました" & strErrorNO & strErrorMes |
100 | return false |
101 | end if |
102 | ###パス |
103 | set strFileName to "weatherapi.html" as text |
104 | set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false |
105 | set listDone to ocidOutputString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference) |
106 | if (item 1 of listDone) is true then |
107 | set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace() |
108 | set boolDone to appSharedWorkspace's openURL:(ocidSaveFilePathURL) |
109 | |
110 | else if (item 1 of listDone) is false then |
111 | log (item 2 of listDone)'s localizedDescription() as text |
112 | return "保存に失敗しました" |
113 | end if |
114 | |
115 | return ocidOutputString as text |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | to doGetDateNo(strDateFormat) |
122 | ####日付情報の取得 |
123 | set ocidDate to current application's NSDate's |date|() |
124 | ###日付のフォーマットを定義 |
125 | set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init() |
126 | ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX") |
127 | ocidNSDateFormatter's setDateFormat:strDateFormat |
128 | set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate |
129 | set strDateAndTime to ocidDateAndTime as text |
130 | return strDateAndTime |
131 | end doGetDateNo |
132 | |
AppleScriptで生成しました |
[bash]Teamsの最新バージョンを取得する
リダイレクト先は同じ
#旧Classic版のURLだけど今は最新版にリダイレクトされる
https://go.microsoft.com/fwlink/?linkid=869428
#最新版
https://go.microsoft.com/fwlink/?linkid=2249065
#リダイレクト先
https://statics.teams.cdn.office.net/production-osx/enterprise/webview2/lkg/MicrosoftTeams.pkg
ホストは3つにわかれている
若干役割が違うようにするために分けたんだろうけど
実際は中身は同じ場合もある
例
バージョン 25060.203.3471.5023の場合
https://statics.teams.cdn.office.net/production-osx/25060.203.3471.5023/MicrosoftTeams.pkg
https://staticsint.teams.cdn.office.net/production-osx/25060.203.3471.5023/MicrosoftTeams.pkg
https://installer.teams.static.microsoft/production-osx/25060.203.3471.5023/MicrosoftTeams.pkg
この3つのURL
中身は同じ
Teamsの最新バージョンを取得する.bash
サンプルコード
行番号 | ソース |
---|---|
001 | #!/bin/bash |
002 | #com.cocolog-nifty.quicktimer.icefloe |
003 | #set -x |
004 | #export PATH=/usr/bin:/bin:/usr/sbin:/sbin |
005 | # MicrosoftTeams-msinternal を参考にしました |
006 | # https://github.com/ItzLevvie/MicrosoftTeams-msinternal |
007 | ################################################# |
008 | |
009 | STR_URL="https://config.teams.microsoft.com/config/v1/MicrosoftTeams/28_1.0.0.0?environment=prod&audienceGroup=general&teamsRing=general&id=3a7cf1d3-06fa-4ead-bf45-a6286ff2620a&tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47&agent=TeamsBuilds" |
010 | |
011 | STR_VERSION=$(/usr/bin/nscurl "$STR_URL" | /usr/bin/jq -r '.BuildSettings.WebView2.macOS.latestVersion') |
012 | /bin/echo "$STR_VERSION" |
013 | |
014 | STR_PKG_URL=$(/usr/bin/nscurl "$STR_URL" | /usr/bin/jq -r '.BuildSettings.WebView2.macOS.buildLink') |
015 | /bin/echo "$STR_PKG_URL" |
016 | |
017 | |
018 | exit 0 |
AppleScriptで生成しました |
[appleScript]Teamsの最新バージョンを取得する
ソース | |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | (* |
004 | MicrosoftTeams-msinternal を参考にしました |
005 | https://github.com/ItzLevvie/MicrosoftTeams-msinternal |
006 | |
007 | v1.1 テキスト出力するようにした |
008 | com.cocolog-nifty.quicktimer.icefloe *) |
009 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
010 | use AppleScript version "2.8" |
011 | use framework "Foundation" |
012 | use framework "AppKit" |
013 | use scripting additions |
014 | |
015 | property refMe : a reference to current application |
016 | |
017 | #28 or 50がMacOS |
018 | set strPlatformId to ("28") as text |
019 | #dev prod life gcc |
020 | set strEnvironment to ("prod") as text |
021 | #ring0 ring3_9 general general_gcc |
022 | set strRing to ("general") as text |
023 | set strObjectId to ("3a7cf1d3-06fa-4ead-bf45-a6286ff2620a") as text |
024 | set strTenantId to ("72f988bf-86f1-41af-91ab-2d7cd011db47") as text |
025 | |
026 | |
027 | set strURL to ("https://config.teams.microsoft.com/config/v1/MicrosoftTeams/" & strPlatformId & "_1.0.0.0?environment=" & strEnvironment & "&audienceGroup=" & strRing & "&teamsRing=" & strRing & "&agent=TeamsBuilds") as text |
028 | |
029 | set strURL to ("https://config.teams.microsoft.com/config/v1/MicrosoftTeams/" & strPlatformId & "_1.0.0.0?environment=" & strEnvironment & "&audienceGroup=" & strRing & "&teamsRing=" & strRing & "&id=" & strObjectId & "&tenantId=" & strTenantId & "&agent=TeamsBuilds") as text |
030 | |
031 | log "\r" & strURL & "\r" |
032 | |
033 | set ocidURLString to refMe's NSString's stringWithString:(strURL) |
034 | set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLString) |
035 | |
036 | |
037 | ##NSDATA |
038 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
039 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidURL) options:(ocidOption) |error|:(reference) |
040 | if (item 2 of listResponse) = (missing value) then |
041 | set ocidReadJsonData to (item 1 of listResponse) |
042 | else if (item 2 of listResponse) ≠ (missing value) then |
043 | set strErrorNO to (item 2 of listResponse)'s code() as text |
044 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
045 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
046 | return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes |
047 | end if |
048 | |
049 | |
050 | #################### |
051 | #JSON ルートがDICT |
052 | set ocidOption to (refMe's NSJSONReadingJSON5Allowed) |
053 | set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadJsonData) options:(ocidOption) |error|:(reference)) |
054 | if (item 2 of listResponse) = (missing value) then |
055 | set ocidJsonDict to (item 1 of listResponse) |
056 | else if (item 2 of listResponse) ≠ (missing value) then |
057 | set strErrorNO to (item 2 of listResponse)'s code() as text |
058 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
059 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
060 | return "JSONObjectWithData エラーしました" & strErrorNO & strErrorMes |
061 | end if |
062 | |
063 | #################### |
064 | # |
065 | set ocidBuildDict to ocidJsonDict's objectForKey:("BuildSettings") |
066 | set ocidWebView2Dict to ocidBuildDict's objectForKey:("WebView2") |
067 | set ocidmacOSDict to ocidWebView2Dict's objectForKey:("macOS") |
068 | set ocidVersion to ocidmacOSDict's valueForKey:("latestVersion") |
069 | set ocidPkgURL to ocidmacOSDict's valueForKey:("buildLink") |
070 | log ocidVersion as text |
071 | log ocidPkgURL as text |
072 | |
073 | set strVersion to (ocidJsonDict's valueForKeyPath:("BuildSettings.WebView2.macOS.latestVersion")) as text |
074 | set strPkgURL to (ocidJsonDict's valueForKeyPath:("BuildSettings.WebView2.macOS.buildLink")) as text |
075 | |
076 | log strVersion |
077 | log strPkgURL |
078 | |
079 | #################### |
080 | #出力用 |
081 | set ocidOutPutString to refMe's NSMutableString's alloc()'s init() |
082 | ocidOutPutString's appendString:("\n") |
083 | |
084 | set strFwlink to ("https://go.microsoft.com/fwlink/?linkid=869428") as text |
085 | ocidOutPutString's appendString:(strFwlink) |
086 | ocidOutPutString's appendString:("\n") |
087 | set strFwlink to ("https://go.microsoft.com/fwlink/?linkid=2249065") as text |
088 | ocidOutPutString's appendString:(strFwlink) |
089 | ocidOutPutString's appendString:("\n") |
090 | |
091 | set strEnterpriseURL to ("https://statics.teams.cdn.office.net/production-osx/enterprise/webview2/lkg/MicrosoftTeams.pkg") as text |
092 | ocidOutPutString's appendString:(strEnterpriseURL) |
093 | ocidOutPutString's appendString:("\n") |
094 | |
095 | set strEnterpriseURL to ("https://statics.teams.cdn.office.net/production-osx/" & strVersion & "/MicrosoftTeams.pkg") as text |
096 | ocidOutPutString's appendString:(strEnterpriseURL) |
097 | ocidOutPutString's appendString:("\n") |
098 | set strEnterpriseURL to ("https://staticsint.teams.cdn.office.net/production-osx/" & strVersion & "/MicrosoftTeams.pkg") as text |
099 | ocidOutPutString's appendString:(strEnterpriseURL) |
100 | ocidOutPutString's appendString:("\n") |
101 | set strEnterpriseURL to ("https://installer.teams.static.microsoft/production-osx/" & strVersion & "/MicrosoftTeams.pkg") as text |
102 | ocidOutPutString's appendString:(strEnterpriseURL) |
103 | ocidOutPutString's appendString:("\n") |
104 | |
105 | #################### |
106 | #保存 |
107 | set appFileManager to refMe's NSFileManager's defaultManager() |
108 | set ocidTempDirURL to appFileManager's temporaryDirectory() |
109 | set ocidUUID to refMe's NSUUID's alloc()'s init() |
110 | set ocidUUIDString to ocidUUID's UUIDString |
111 | set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true) |
112 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init() |
113 | ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions) |
114 | set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference) |
115 | ###パス |
116 | set strFileName to "index.txt" as text |
117 | set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false |
118 | set listDone to ocidOutPutString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference) |
119 | #開く |
120 | set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace() |
121 | set boolDone to appSharedWorkspace's openURL:(ocidSaveFilePathURL) |
122 | |
123 | |
AppleScriptで生成しました |
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | (* |
004 | MicrosoftTeams-msinternal を参考にしました |
005 | https://github.com/ItzLevvie/MicrosoftTeams-msinternal |
006 | |
007 | com.cocolog-nifty.quicktimer.icefloe *) |
008 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
009 | use AppleScript version "2.8" |
010 | use framework "Foundation" |
011 | use framework "AppKit" |
012 | use scripting additions |
013 | |
014 | property refMe : a reference to current application |
015 | |
016 | #28 or 50がMacOS |
017 | set strPlatformId to ("28") as text |
018 | #dev prod life gcc |
019 | set strEnvironment to ("prod") as text |
020 | #ring0 ring3_9 general general_gcc |
021 | set strRing to ("general") as text |
022 | set strObjectId to ("3a7cf1d3-06fa-4ead-bf45-a6286ff2620a") as text |
023 | set strTenantId to ("72f988bf-86f1-41af-91ab-2d7cd011db47") as text |
024 | |
025 | |
026 | set strURL to ("https://config.teams.microsoft.com/config/v1/MicrosoftTeams/" & strPlatformId & "_1.0.0.0?environment=" & strEnvironment & "&audienceGroup=" & strRing & "&teamsRing=" & strRing & "&agent=TeamsBuilds") as text |
027 | |
028 | set strURL to ("https://config.teams.microsoft.com/config/v1/MicrosoftTeams/" & strPlatformId & "_1.0.0.0?environment=" & strEnvironment & "&audienceGroup=" & strRing & "&teamsRing=" & strRing & "&id=" & strObjectId & "&tenantId=" & strTenantId & "&agent=TeamsBuilds") as text |
029 | |
030 | |
031 | set ocidURLString to refMe's NSString's stringWithString:(strURL) |
032 | set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLString) |
033 | |
034 | |
035 | ##NSDATA |
036 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
037 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidURL) options:(ocidOption) |error|:(reference) |
038 | if (item 2 of listResponse) = (missing value) then |
039 | set ocidReadJsonData to (item 1 of listResponse) |
040 | else if (item 2 of listResponse) ≠ (missing value) then |
041 | set strErrorNO to (item 2 of listResponse)'s code() as text |
042 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
043 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
044 | return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes |
045 | end if |
046 | |
047 | |
048 | #################### |
049 | #JSON ルートがDICT |
050 | set ocidOption to (refMe's NSJSONReadingJSON5Allowed) |
051 | set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadJsonData) options:(ocidOption) |error|:(reference)) |
052 | if (item 2 of listResponse) = (missing value) then |
053 | set ocidJsonDict to (item 1 of listResponse) |
054 | else if (item 2 of listResponse) ≠ (missing value) then |
055 | set strErrorNO to (item 2 of listResponse)'s code() as text |
056 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
057 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
058 | return "JSONObjectWithData エラーしました" & strErrorNO & strErrorMes |
059 | end if |
060 | |
061 | #################### |
062 | # |
063 | set ocidBuildDict to ocidJsonDict's objectForKey:("BuildSettings") |
064 | set ocidWebView2Dict to ocidBuildDict's objectForKey:("WebView2") |
065 | set ocidmacOSDict to ocidWebView2Dict's objectForKey:("macOS") |
066 | set ocidVersion to ocidmacOSDict's valueForKey:("latestVersion") |
067 | set ocidPkgURL to ocidmacOSDict's valueForKey:("buildLink") |
068 | log ocidVersion as text |
069 | log ocidPkgURL as text |
070 | |
071 | set strVersion to (ocidJsonDict's valueForKeyPath:("BuildSettings.WebView2.macOS.latestVersion")) as text |
072 | set strPkgURL to (ocidJsonDict's valueForKeyPath:("BuildSettings.WebView2.macOS.buildLink")) as text |
073 | |
074 | log strVersion |
075 | log strPkgURL |
[AppleScript]気象庁のJSON取得してテキスト出力する
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | (* |
004 | 気象庁のJSON取得 |
005 | Jsonの取得と解析は難しくないが |
006 | 『海がない気象台』『観測所にはURLがない』とかがあることをお忘れなく |
007 | V2 色々直した |
008 | com.cocolog-nifty.quicktimer.icefloe*) |
009 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
010 | use AppleScript version "2.8" |
011 | use framework "Foundation" |
012 | use framework "AppKit" |
013 | use framework "UniformTypeIdentifiers" |
014 | use scripting additions |
015 | |
016 | property refMe : a reference to current application |
017 | |
018 | #################### |
019 | #設定項目 |
020 | set strAreaUrl to "https://www.jma.go.jp/bosai/common/const/area.json" |
021 | |
022 | |
023 | #################### |
024 | #出力用テキスト |
025 | set ocidOutPutArray to refMe's NSMutableArray's alloc()'s init() |
026 | |
027 | #################### |
028 | #URL |
029 | set ocidAreaUrlStr to refMe's NSString's stringWithString:(strAreaUrl) |
030 | set ocidAreaURL to refMe's NSURL's alloc()'s initWithString:(ocidAreaUrlStr) |
031 | |
032 | #################### |
033 | #NSDATA |
034 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
035 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidAreaURL) options:(ocidOption) |error|:(reference) |
036 | if (item 2 of listResponse) = (missing value) then |
037 | log "initWithContentsOfURL 正常処理" |
038 | set ocidReadJsonData to (item 1 of listResponse) |
039 | else if (item 2 of listResponse) ≠ (missing value) then |
040 | set strErrorNO to (item 2 of listResponse)'s code() as text |
041 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
042 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
043 | return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes |
044 | end if |
045 | #################### |
046 | #JSON ルートがDICT |
047 | set ocidOption to (refMe's NSJSONReadingJSON5Allowed) |
048 | set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadJsonData) options:(ocidOption) |error|:(reference)) |
049 | if (item 2 of listResponse) = (missing value) then |
050 | log "JSONObjectWithData 正常処理" |
051 | set ocidJsonDict to (item 1 of listResponse) |
052 | else if (item 2 of listResponse) ≠ (missing value) then |
053 | set strErrorNO to (item 2 of listResponse)'s code() as text |
054 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
055 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
056 | return "JSONObjectWithData エラーしました" & strErrorNO & strErrorMes |
057 | end if |
058 | #################### |
059 | #centers |
060 | set ocidCentersDict to ocidJsonDict's objectForKey:("centers") |
061 | set ocidCentersArray to ocidCentersDict's allKeys() |
062 | #ソート |
063 | set ocidCentersArray to ocidCentersArray's sortedArrayUsingSelector:("compare:") |
064 | #ダイアログ用の地方気象台名リスト |
065 | set listCenterName to {} as list |
066 | #逆引きDICT |
067 | set ocidReverseCenterDict to refMe's NSMutableDictionary's alloc()'s init() |
068 | repeat with itemKey in ocidCentersArray |
069 | set ocidCenter to (ocidCentersDict's valueForKey:(itemKey)) |
070 | set strCenterName to (ocidCenter's valueForKey:("officeName")) as text |
071 | copy strCenterName to end of listCenterName |
072 | (ocidReverseCenterDict's setValue:(itemKey) forKey:(strCenterName)) |
073 | end repeat |
074 | |
075 | #################### |
076 | #ダイアログ |
077 | set strName to (name of current application) as text |
078 | if strName is "osascript" then |
079 | tell application "SystemUIServer" to activate |
080 | else |
081 | tell current application to activate |
082 | end if |
083 | try |
084 | tell application "SystemUIServer" |
085 | activate |
086 | set valueResponse to (choose from list listCenterName with title "選んでください" with prompt "地方気象台を選んでください" default items (item 3 of listCenterName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) |
087 | end tell |
088 | on error |
089 | tell application "SystemUIServer" to quit |
090 | log "Error choose from list" |
091 | return false |
092 | end try |
093 | tell application "SystemUIServer" to quit |
094 | if (class of valueResponse) is boolean then |
095 | log "Error キャンセルしました" |
096 | error "ユーザによってキャンセルされました。" number -128 |
097 | else if (class of valueResponse) is list then |
098 | if valueResponse is {} then |
099 | log "Error 何も選んでいません" |
100 | return false |
101 | else |
102 | set strResponse to (item 1 of valueResponse) as text |
103 | end if |
104 | end if |
105 | set ocidOutPutStrint to refMe's NSString's stringWithString:("天気予報: Center: " & strResponse & "\n") |
106 | (ocidOutPutArray's addObject:(ocidOutPutStrint)) |
107 | #################### |
108 | #逆引き辞書からセンター番号を取得 |
109 | set ocidCenterNo to ocidReverseCenterDict's valueForKey:(strResponse) |
110 | #センター番号からOffice情報を取得 |
111 | set ocidOfficeDict to (ocidCentersDict's objectForKey:(ocidCenterNo)) |
112 | #Office情報 DICTから気象台番号を取得 |
113 | set ocidOfficeNoArray to (ocidOfficeDict's objectForKey:("children")) |
114 | set ocidOfficeNoArray to ocidOfficeNoArray's sortedArrayUsingSelector:("compare:") |
115 | |
116 | #################### |
117 | #offices |
118 | set ocidOfficesDict to ocidJsonDict's objectForKey:("offices") |
119 | set ocidOfficesArray to ocidOfficesDict's allKeys() |
120 | #測候所はURLがないので除外 |
121 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "測候所") |
122 | set ocidOfficesArrayRev to ocidOfficesArray's filteredArrayUsingPredicate:(appPredicate) |
123 | set ocidOfficesArray to ocidOfficesArrayRev's sortedArrayUsingSelector:("compare:") |
124 | #ダイアログ用の気象台名リスト |
125 | set listOfficesName to {} as list |
126 | #逆引きDICT |
127 | set ocidReverseOfficesDict to refMe's NSMutableDictionary's alloc()'s init() |
128 | repeat with itemKey in ocidOfficeNoArray |
129 | set ocidOffice to (ocidOfficesDict's valueForKey:(itemKey)) |
130 | set strOfficeName to (ocidOffice's valueForKey:("officeName")) as text |
131 | if strOfficeName does not contain "測候所" then |
132 | copy strOfficeName to end of listOfficesName |
133 | (ocidReverseOfficesDict's setValue:(itemKey) forKey:(strOfficeName)) |
134 | end if |
135 | end repeat |
136 | |
137 | |
138 | #################### |
139 | #ダイアログ |
140 | set strName to (name of current application) as text |
141 | if strName is "osascript" then |
142 | tell application "SystemUIServer" to activate |
143 | else |
144 | tell current application to activate |
145 | end if |
146 | try |
147 | tell application "SystemUIServer" |
148 | activate |
149 | set valueResponse to (choose from list listOfficesName with title "選んでください" with prompt "気象台を選んでください" default items (last item of listOfficesName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) |
150 | end tell |
151 | on error |
152 | tell application "SystemUIServer" to quit |
153 | log "Error choose from list" |
154 | return false |
155 | end try |
156 | tell application "SystemUIServer" to quit |
157 | if (class of valueResponse) is boolean then |
158 | log "Error キャンセルしました" |
159 | error "ユーザによってキャンセルされました。" number -128 |
160 | else if (class of valueResponse) is list then |
161 | if valueResponse is {} then |
162 | log "Error 何も選んでいません" |
163 | return false |
164 | else |
165 | set strResponse to (item 1 of valueResponse) as text |
166 | end if |
167 | end if |
168 | set ocidOutPutStrint to refMe's NSString's stringWithString:("Office: " & strResponse & " 発表\n") |
169 | (ocidOutPutArray's addObject:(ocidOutPutStrint)) |
170 | |
171 | ####################### |
172 | #本処理 天気予報jSON取得 |
173 | set ocidOfficeNo to ocidReverseOfficesDict's valueForKey:(strResponse) |
174 | set strOfficeNo to ocidOfficeNo as text |
175 | #日付 |
176 | set strDate to doGetDateNo("yyyyMMddhhmmss") as text |
177 | ###URL整形 |
178 | set strURL to ("https://www.jma.go.jp/bosai/forecast/data/forecast/" & strOfficeNo & ".json?__time__=" & strDate & "") as text |
179 | log "\r" & strURL & "\r" |
180 | #################### |
181 | #URL |
182 | set ocidUrlStr to refMe's NSString's stringWithString:(strURL) |
183 | set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidUrlStr) |
184 | |
185 | #################### |
186 | #NSDATA |
187 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
188 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidURL) options:(ocidOption) |error|:(reference) |
189 | if (item 2 of listResponse) = (missing value) then |
190 | log "initWithContentsOfURL 正常処理" |
191 | set ocidReadJsonData to (item 1 of listResponse) |
192 | else if (item 2 of listResponse) ≠ (missing value) then |
193 | set strErrorNO to (item 2 of listResponse)'s code() as text |
194 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
195 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
196 | return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes |
197 | end if |
198 | #################### |
199 | #JSON ルートがArray |
200 | set ocidOption to (refMe's NSJSONReadingJSON5Allowed) |
201 | set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadJsonData) options:(ocidOption) |error|:(reference)) |
202 | if (item 2 of listResponse) = (missing value) then |
203 | log "JSONObjectWithData 正常処理" |
204 | set ocidJsonArray to (item 1 of listResponse) |
205 | else if (item 2 of listResponse) ≠ (missing value) then |
206 | set strErrorNO to (item 2 of listResponse)'s code() as text |
207 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
208 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
209 | return "JSONObjectWithData エラーしました" & strErrorNO & strErrorMes |
210 | end if |
211 | #################### |
212 | #天気予報辞書 天気予報 と 習慣天気予報 |
213 | set ocidDailyDict to ocidJsonArray's firstObject() |
214 | set ocidWeeklyDict to ocidJsonArray's firstObject() |
215 | |
216 | #################### |
217 | #各項目取得 |
218 | set ocidTimeSeriesArray to ocidDailyDict's objectForKey:("timeSeries") |
219 | set ocidWeathers to ocidTimeSeriesArray's firstObject() |
220 | set ocidRainPops to ocidTimeSeriesArray's objectAtIndex:(1) |
221 | set ocidTemps to ocidTimeSeriesArray's lastObject() |
222 | |
223 | #################### |
224 | #天気予報 |
225 | set strOutPutStrint to ("") as text |
226 | set ocidAreaArray to ocidWeathers's objectForKey:("areas") |
227 | repeat with itemArea in ocidAreaArray |
228 | set strAreaName to ((itemArea's objectForKey:("area"))'s valueForKey:("name")) as text |
229 | set ocidWeathersArray to (itemArea's objectForKey:("weathers")) |
230 | set ocidWindsArray to (itemArea's objectForKey:("winds")) |
231 | set ocidWavesArray to (itemArea's objectForKey:("waves")) |
232 | set numCntWavesArray to ocidWavesArray's |count|() |
233 | repeat with itemNo from 0 to (numCntWavesArray - 1) by 1 |
234 | set strOutPutStrint to ("" & strOutPutStrint & strAreaName & "地方\n") as text |
235 | if itemNo = 0 then |
236 | set strOutPutStrint to ("" & strOutPutStrint & "今日の天気: ") as text |
237 | else if itemNo = 1 then |
238 | set strOutPutStrint to ("" & strOutPutStrint & "明日の天気: ") as text |
239 | else if itemNo = 2 then |
240 | set strOutPutStrint to ("" & strOutPutStrint & "明後日の天気: ") as text |
241 | end if |
242 | set strSetString to (ocidWeathersArray's objectAtIndex:(itemNo)) |
243 | set strOutPutStrint to ("" & strOutPutStrint & strSetString & "\n\t風: ") as text |
244 | set strSetString to (ocidWindsArray's objectAtIndex:(itemNo)) |
245 | set strOutPutStrint to ("" & strOutPutStrint & strSetString & "\n") as text |
246 | if ocidWavesArray ≠ (missing value) then |
247 | set strSetString to (ocidWavesArray's objectAtIndex:(itemNo)) |
248 | set strOutPutStrint to ("" & strOutPutStrint & "\t波: " & strSetString & "\n") as text |
249 | end if |
250 | end repeat |
251 | set strOutPutStrint to ("" & strOutPutStrint & "\n") as text |
252 | end repeat |
253 | set ocidOutPutStrint to refMe's NSString's stringWithString:(strOutPutStrint) |
254 | ocidOutPutArray's addObject:(ocidOutPutStrint) |
255 | #################### |
256 | #降雨確率 |
257 | set strOutPutStrint to ("降水確率(6時間毎):\n") as text |
258 | set ocidAreaArray to ocidRainPops's objectForKey:("areas") |
259 | repeat with itemArea in ocidAreaArray |
260 | set ocidAreaName to ((itemArea's objectForKey:("area"))'s valueForKey:("name")) |
261 | set strOutPutStrint to ("" & strOutPutStrint & ocidAreaName & "地域: ") as text |
262 | set ocidPopsString to ((itemArea's objectForKey:("pops"))'s componentsJoinedByString:("→")) |
263 | set strOutPutStrint to ("" & strOutPutStrint & ocidPopsString & "\n") as text |
264 | end repeat |
265 | set ocidOutPutStrint to refMe's NSString's stringWithString:(strOutPutStrint) |
266 | ocidOutPutArray's addObject:(ocidOutPutStrint) |
267 | #################### |
268 | #気温 |
269 | set strOutPutStrint to ("気温(12時間毎):\n") as text |
270 | set ocidAreaArray to ocidTemps's objectForKey:("areas") |
271 | repeat with itemArea in ocidAreaArray |
272 | set ocidAreaName to ((itemArea's objectForKey:("area"))'s valueForKey:("name")) |
273 | set strOutPutStrint to ("" & strOutPutStrint & ocidAreaName & "地域: ") as text |
274 | set ocidTempString to ((itemArea's objectForKey:("temps"))'s componentsJoinedByString:("→")) |
275 | set strOutPutStrint to ("" & strOutPutStrint & ocidTempString & "\n") as text |
276 | end repeat |
277 | set ocidOutPutStrint to refMe's NSString's stringWithString:(strOutPutStrint) |
278 | (ocidOutPutArray's addObject:(ocidOutPutStrint)) |
279 | |
280 | #################### |
281 | #出力用テキスト |
282 | set ocidJoinText to ocidOutPutArray's componentsJoinedByString:("\n") |
283 | #保存先 |
284 | set appFileManager to refMe's NSFileManager's defaultManager() |
285 | set ocidTempDirURL to appFileManager's temporaryDirectory() |
286 | set ocidUUID to refMe's NSUUID's alloc()'s init() |
287 | set ocidUUIDString to ocidUUID's UUIDString |
288 | set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true) |
289 | # |
290 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init() |
291 | ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions) |
292 | set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference) |
293 | if (item 1 of listDone) is false then |
294 | set strErrorNO to (item 2 of listDone)'s code() as text |
295 | set strErrorMes to (item 2 of listDone)'s localizedDescription() as text |
296 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
297 | log "createDirectoryAtURL エラーしました" & strErrorNO & strErrorMes |
298 | return false |
299 | end if |
300 | ###パス |
301 | set strFileName to "jma.txt" as text |
302 | set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false |
303 | |
304 | set listDone to ocidJoinText's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference) |
305 | if (item 1 of listDone) is true then |
306 | set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace() |
307 | set boolDone to appSharedWorkspace's openURL:(ocidSaveFilePathURL) |
308 | |
309 | else if (item 1 of listDone) is false then |
310 | log (item 2 of listDone)'s localizedDescription() as text |
311 | return "保存に失敗しました" |
312 | end if |
313 | |
314 | |
315 | return ocidJoinText as text |
316 | |
317 | |
318 | |
319 | |
320 | |
321 | to doGetDateNo(strDateFormat) |
322 | ####日付情報の取得 |
323 | set ocidDate to current application's NSDate's |date|() |
324 | ###日付のフォーマットを定義 |
325 | set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init() |
326 | ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX") |
327 | ocidNSDateFormatter's setDateFormat:strDateFormat |
328 | set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate |
329 | set strDateAndTime to ocidDateAndTime as text |
330 | return strDateAndTime |
331 | end doGetDateNo |
332 |
[JSON]JSONの編集基本的な流れ
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | # |
005 | #com.cocolog-nifty.quicktimer.icefloe |
006 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
007 | use AppleScript version "2.8" |
008 | use framework "Foundation" |
009 | use framework "AppKit" |
010 | use scripting additions |
011 | property refMe : a reference to current application |
012 | set appFileManager to refMe's NSFileManager's defaultManager() |
013 | ################################### |
014 | #パス |
015 | set strFilePath to "~/Desktop/Jsonまでのパス.json" as text |
016 | set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath) |
017 | set ocidFilePath to ocidFilePathStr's stringByStandardizingPath() |
018 | set ocidJsonFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false) |
019 | |
020 | ################################### |
021 | ## JSONをバックアップ |
022 | #拡張子とって |
023 | set ocidBaseFilePathURL to ocidJsonFilePathURL's URLByDeletingPathExtension() |
024 | set strDateNo to doGetDateNo("yyyyMMdd") |
025 | #日付入りにして |
026 | set strSetValue to ("" & strDateNo & ".json") |
027 | set ocidBakupJsonFilePathURL to ocidBaseFilePathURL's URLByAppendingPathExtension:(strSetValue) |
028 | #バックアップ |
029 | set listDone to (appFileManager's copyItemAtURL:(ocidJsonFilePathURL) toURL:(ocidBakupJsonFilePathURL) |error| :(reference)) |
030 | if (item 1 of listDone) is true then |
031 | log "copyItemAtURL 正常処理" |
032 | else if (item 2 of listDone) ≠ (missing value) then |
033 | set strErrorNO to (item 2 of listDone)'s code() as text |
034 | set strErrorMes to (item 2 of listDone)'s localizedDescription() as text |
035 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
036 | log "エラーしました" & strErrorNO & strErrorMes |
037 | doExecAlert("copyItemAtURL でエラーしました") |
038 | end if |
039 | |
040 | ################################### |
041 | ## SDATAに読み込む |
042 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
043 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidJsonFilePathURL) options:(ocidOption) |error| :(reference) |
044 | if (item 2 of listResponse) = (missing value) then |
045 | log "initWithContentsOfURL 正常処理" |
046 | set ocidReadData to (item 1 of listResponse) |
047 | else if (item 2 of listResponse) ≠ (missing value) then |
048 | set strErrorNO to (item 2 of listResponse)'s code() as text |
049 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
050 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
051 | log "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes |
052 | doExecAlert("initWithContentsOfURL でエラーしました") |
053 | end if |
054 | ################################### |
055 | ## JSONObjectWithData |
056 | set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadData) options:(refMe's NSJSONReadingMutableContainers) |error| :(reference)) |
057 | if (item 2 of listResponse) = (missing value) then |
058 | log "JSONObjectWithData 正常処理" |
059 | set ocidJsonData to item 1 of listResponse |
060 | else if (item 2 of listResponse) ≠ (missing value) then |
061 | set strErrorNO to (item 2 of listResponse)'s code() as text |
062 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
063 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
064 | log "JSONObjectWithData エラーしました" & strErrorNO & strErrorMes |
065 | doExecAlert("JSONObjectWithData") |
066 | end if |
067 | |
068 | |
069 | ################################### |
070 | ## ROOT構造がArrayか?DICTか?の判定 |
071 | #確認できたら不要 |
072 | set boolArrayM to ocidJsonData's isKindOfClass:(refMe's NSMutableArray's class) |
073 | set boolArray to ocidJsonData's isKindOfClass:(refMe's NSArray's class) |
074 | set boolDictM to ocidJsonData's isKindOfClass:(refMe's NSMutableDictionary's class) |
075 | set boolDict to ocidJsonData's isKindOfClass:(refMe's NSDictionary's class) |
076 | # |
077 | if boolArrayM is true then |
078 | log "root ARRAY構造です 可変" |
079 | set ocidJsonArray to ocidJsonData |
080 | else if boolArray is true then |
081 | log "root ARRAY構造です フローズンなので mutableCopy" |
082 | set ocidJsonArray to ocidJsonData's mutableCopy() |
083 | else if boolDictM is true then |
084 | log "root DICT構造です 可変" |
085 | set ocidJsonDict to ocidJsonData |
086 | else if boolDict is true then |
087 | log "root DICT構造です フローズンなので mutableCopy" |
088 | set ocidJsonDict to ocidJsonData's mutableCopy() |
089 | end if |
090 | |
091 | ################################### |
092 | # ここで各種処理する |
093 | |
094 | |
095 | ################################### |
096 | #ROOTの構造を確認できたら不要 |
097 | if boolArrayM is true then |
098 | set ocidPlistData to ocidJsonArray |
099 | else if boolArray is true then |
100 | set ocidPlistData to ocidJsonArray |
101 | else if boolDictM is true then |
102 | set ocidPlistData to ocidJsonDict |
103 | else if boolDict is true then |
104 | set ocidPlistData to ocidJsonDict |
105 | end if |
106 | |
107 | ################################### |
108 | # dataWithJSONObject でNSDATAにして |
109 | set listResponse to (refMe's NSJSONSerialization's dataWithJSONObject:(ocidPlistData) options:(refMe's NSJSONReadingJSON5Allowed) |error| :(reference)) |
110 | if (item 2 of listResponse) is (missing value) then |
111 | set ocidJsonData to (item 1 of listResponse) |
112 | log "dataWithJSONObject 正常終了" |
113 | else |
114 | set strErrorNO to (item 2 of listResponse)'s code() as text |
115 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
116 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
117 | doExecAlert("dataWithJSONObject でエラーしました") |
118 | end if |
119 | |
120 | ################################### |
121 | # 保存 |
122 | set ocidOption to (refMe's NSDataWritingAtomic) |
123 | set listDone to ocidJsonData's writeToURL:(ocidJsonFilePathURL) options:(ocidOption) |error| :(reference) |
124 | if (item 1 of listDone) is true then |
125 | log "writeToURL 正常終了" |
126 | else if (item 1 of listDone) is false then |
127 | set strErrorNO to (item 2 of listDone)'s code() as text |
128 | set strErrorMes to (item 2 of listDone)'s localizedDescription() as text |
129 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
130 | doExecAlert("writeToURL 失敗しました") |
131 | return "writeToURL 失敗しました" |
132 | end if |
133 | |
134 | |
135 | ########################## |
136 | #【K】エラーアラート |
137 | to doExecAlert(argMessageText) |
138 | #ダイアログを前面に出す |
139 | set strName to (name of current application) as text |
140 | if strName is "osascript" then |
141 | tell application "Finder" to activate |
142 | else |
143 | tell current application to activate |
144 | end if |
145 | try |
146 | set recordResponse to (display alert argMessageText buttons {"終了", "再実行"} default button "終了" cancel button "終了" as informational giving up after 5) as record |
147 | on error |
148 | log "エラーしました" |
149 | return "キャンセルしました。" |
150 | end try |
151 | if true is equal to (gave up of recordResponse) then |
152 | return "時間切れです。" |
153 | end if |
154 | set strBottonName to (button returned of recordResponse) as text |
155 | if "再実行" is equal to (strBottonName) then |
156 | tell application "Finder" |
157 | set aliasPathToMe to (path to me) as alias |
158 | end tell |
159 | run script aliasPathToMe with parameters "再実行" |
160 | return |
161 | else if "終了" is equal to (strBottonName) then |
162 | return "終了を確認しました。" |
163 | else if "中断" is equal to (strBottonName) then |
164 | return "中断" |
165 | end if |
166 | end doExecAlert |
167 | |
168 | ########################## |
169 | #日付の取得 |
170 | to doGetDateNo(strDateFormat) |
171 | ####日付情報の取得 |
172 | set ocidDate to current application's NSDate's |date|() |
173 | ###日付のフォーマットを定義 |
174 | set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init() |
175 | ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX") |
176 | ocidNSDateFormatter's setDateFormat:strDateFormat |
177 | set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate |
178 | set strDateAndTime to ocidDateAndTime as text |
179 | return strDateAndTime |
180 | end doGetDateNo |
AppleScriptで生成しました |
| 固定リンク
[Json]Jsonファイルをplistに変換する(保存先指定できるようにした)
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | (* com.cocolog-nifty.quicktimer.icefloe |
004 | Json2Plist |
005 | JSON形式のテキストをPLISTに変換します |
006 | v2 jsonのrootの構造がArrayなのか?DICTなのか?の判定を入れた |
007 | 保存先をデスクトップに変更した |
008 | 保存先を選べるようにした |
009 | *) |
010 | # |
011 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
012 | ##自分環境がos12なので2.8にしているだけです |
013 | use AppleScript version "2.8" |
014 | use framework "Foundation" |
015 | use framework "AppKit" |
016 | use scripting additions |
017 | |
018 | property refMe : a reference to current application |
019 | |
020 | |
021 | ####ダイアログで使うデフォルトロケーション |
022 | tell application "Finder" |
023 | set aliasDefaultLocation to (path to desktop folder from user domain) as alias |
024 | end tell |
025 | ####UTIリスト |
026 | set listUTI to {"public.json", "com.netscape.javascript-source"} |
027 | ####ダイアログを出す |
028 | set aliasFilePath to (choose file with prompt "ファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias |
029 | |
030 | set strFilePath to (POSIX path of aliasFilePath) as text |
031 | ########################################## |
032 | ###【1】ドキュメントのパスをNSString |
033 | set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath) |
034 | set ocidFilePath to ocidFilePathStr's stringByStandardizingPath() |
035 | set ocidFilePathURL to refMe's NSURL's fileURLWithPath:(ocidFilePath) |
036 | |
037 | ########################################## |
038 | ### 【2】ファイルをNSDATAとして読み込み |
039 | (* NSDataReadingOptions |
040 | (*1*)log refMe's NSDataReadingMappedIfSafe as integer |
041 | (*2*)log refMe's NSDataReadingUncached as integer |
042 | (*8*)log refMe's NSDataReadingMappedAlways as integer |
043 | *) |
044 | set listReadData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(refMe's NSDataReadingMappedIfSafe) |error| :(reference) |
045 | set coidReadData to item 1 of listReadData |
046 | |
047 | ########################################## |
048 | ### 【3】JSON初期化 |
049 | (* NSJSONReadingOptions |
050 | (*1*)log refMe's NSJSONReadingMutableContainers as integer |
051 | (*2*)log refMe's NSJSONReadingMutableLeaves as integer |
052 | (*4*)log refMe's NSJSONReadingFragmentsAllowed as integer |
053 | (*8*)log refMe's NSJSONReadingJSON5Allowed as integer |
054 | (*16*)log refMe's NSJSONReadingTopLevelDictionaryAssumed as integer |
055 | *) |
056 | set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(coidReadData) options:(refMe's NSJSONReadingMutableContainers) |error| :(reference)) |
057 | set ocidJsonData to item 1 of listJSONSerialization |
058 | #ROOT構造がArrayか?DICTか?の判定 |
059 | set ocidJsonClass to ocidJsonData's className() |
060 | set boolContainArray to ocidJsonClass's containsString:("NSArray") |
061 | |
062 | ########################################## |
063 | ####【4】レコードに格納 |
064 | #実際はここで色々処理したりデータ取得したりします |
065 | |
066 | #最後に出力用に名前を変えて(まぁ必要ないんだけどなんとなく) |
067 | if boolContainArray is false then |
068 | set ocidJsonPlist to refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData) |
069 | else if boolContainArray is true then |
070 | set ocidJsonPlist to refMe's NSArray's alloc()'s initWithArray:(ocidJsonData) |
071 | end if |
072 | |
073 | ########################################## |
074 | ####【5】PLISTに変換 (optionは 0-2 Immutable /MutableContainers /MutableContainersAndLeaves) |
075 | set ocidFromat to refMe's NSPropertyListXMLFormat_v1_0 |
076 | set listPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidJsonData) format:(ocidFromat) options:0 |error| :(reference) |
077 | set ocidPlistEditData to item 1 of listPlistEditDataArray |
078 | |
079 | ########################################## |
080 | ####【6】保存 |
081 | #デスクトップにする |
082 | set appFileManager to refMe's NSFileManager's defaultManager() |
083 | set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask)) |
084 | set ocidDesktopDirPathURL to ocidURLsArray's firstObject() |
085 | set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias |
086 | set ocidFileName to ocidFilePathURL's lastPathComponent() |
087 | set ocidFileExtension to ocidFilePathURL's pathExtension() |
088 | # |
089 | set ocidPrefixName to ocidFileName's stringByDeletingPathExtension() |
090 | set strPrefixName to ocidPrefixName as text |
091 | set ocidContainerDirURL to ocidFilePathURL's URLByDeletingLastPathComponent() |
092 | set strFileExtension to "plist" |
093 | set strDefaultName to (strPrefixName & "." & strFileExtension) as text |
094 | set strPromptText to "名前を決めてください" |
095 | set strMesText to "名前を決めてください" |
096 | |
097 | #ダイアログ |
098 | set strName to (name of current application) as text |
099 | if strName is "osascript" then |
100 | tell application "Finder" to activate |
101 | else |
102 | tell current application to activate |
103 | end if |
104 | set aliasSaveFilePath to (choose file name strMesText default location aliasDefaultLocation default name strDefaultName with prompt strPromptText) as «class furl» |
105 | # |
106 | set strSaveFilePath to(POSIX path of aliasSaveFilePath) as text |
107 | set ocidSaveFilePath to refMe's NSString's stringWithString:(strSaveFilePath) |
108 | set ocidSaveFilePathURL to refMe's NSURL's fileURLWithPath:(ocidSaveFilePath) |
109 | set strFileExtensionName to ocidSaveFilePathURL's pathExtension() as text |
110 | if strFileExtensionName is not strFileExtension then |
111 | set ocidSaveFilePathURL to ocidSaveFilePathURL's URLByAppendingPathExtension:strFileExtension |
112 | end if |
113 | |
114 | |
115 | |
116 | ###保存 |
117 | set boolWritetoUrlArray to ocidPlistEditData's writeToURL:(ocidSaveFilePathURL) options:0 |error| :(reference) |
118 | |
119 | return "処理終了" |
AppleScriptで生成しました |
| 固定リンク
[JSON] JSON 2 PLIST 少し修正
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | (* com.cocolog-nifty.quicktimer.icefloe |
004 | Json2Plist |
005 | JSON形式のテキストをPLISTに変換します |
006 | v2 jsonのrootの構造がArrayなのか?DICTなのか?の判定を入れた |
007 | *) |
008 | # |
009 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
010 | ##自分環境がos12なので2.8にしているだけです |
011 | use AppleScript version "2.8" |
012 | use framework "Foundation" |
013 | use scripting additions |
014 | |
015 | property refMe : a reference to current application |
016 | |
017 | |
018 | ####ダイアログで使うデフォルトロケーション |
019 | tell application "Finder" |
020 | set aliasDefaultLocation to (path to desktop folder from user domain) as alias |
021 | end tell |
022 | ####UTIリスト |
023 | set listUTI to {"public.json", "com.netscape.javascript-source"} |
024 | ####ダイアログを出す |
025 | set aliasFilePath to (choose file with prompt "ファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias |
026 | |
027 | set strFilePath to (POSIX path of aliasFilePath) as text |
028 | ########################################## |
029 | ###【1】ドキュメントのパスをNSString |
030 | set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath) |
031 | set ocidFilePath to ocidFilePathStr's stringByStandardizingPath() |
032 | set ocidFilePathURL to refMe's NSURL's fileURLWithPath:(ocidFilePath) |
033 | |
034 | ########################################## |
035 | ### 【2】ファイルをNSDATAとして読み込み |
036 | (* NSDataReadingOptions |
037 | (*1*)log refMe's NSDataReadingMappedIfSafe as integer |
038 | (*2*)log refMe's NSDataReadingUncached as integer |
039 | (*8*)log refMe's NSDataReadingMappedAlways as integer |
040 | *) |
041 | set listReadData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(refMe's NSDataReadingMappedIfSafe) |error| :(reference) |
042 | set coidReadData to item 1 of listReadData |
043 | |
044 | ########################################## |
045 | ### 【3】JSON初期化 |
046 | (* NSJSONReadingOptions |
047 | (*1*)log refMe's NSJSONReadingMutableContainers as integer |
048 | (*2*)log refMe's NSJSONReadingMutableLeaves as integer |
049 | (*4*)log refMe's NSJSONReadingFragmentsAllowed as integer |
050 | (*8*)log refMe's NSJSONReadingJSON5Allowed as integer |
051 | (*16*)log refMe's NSJSONReadingTopLevelDictionaryAssumed as integer |
052 | *) |
053 | set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(coidReadData) options:(refMe's NSJSONReadingMutableContainers) |error| :(reference)) |
054 | set ocidJsonData to item 1 of listJSONSerialization |
055 | #ROOT構造がArrayか?DICTか?の判定 |
056 | set ocidJsonClass to ocidJsonData's className()'s stringValue() |
057 | set boolContainArray to ocidJsonClass's containsString:("NSArray") |
058 | |
059 | ########################################## |
060 | ####【4】レコードに格納 |
061 | #実際はここで色々処理したりデータ取得したりします |
062 | |
063 | #最後に出力用に名前を変えて(まぁ必要ないんだけどなんとなく) |
064 | if boolContainArray is false then |
065 | set ocidJsonPlist to refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData) |
066 | else if boolContainArray is true then |
067 | set ocidJsonPlist to refMe's NSArray's alloc()'s initWithArray:(ocidJsonData) |
068 | end if |
069 | |
070 | ########################################## |
071 | ####【5】PLISTに変換 (optionは 0-2 Immutable /MutableContainers /MutableContainersAndLeaves) |
072 | set ocidFromat to refMe's NSPropertyListXMLFormat_v1_0 |
073 | set listPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidJsonData) format:(ocidFromat) options:0 |error| :(reference) |
074 | set ocidPlistEditData to item 1 of listPlistEditDataArray |
075 | |
076 | ########################################## |
077 | ####【6】保存 |
078 | ###保存先パスをURLを生成して |
079 | set ocidBaseFileURL to ocidFilePathURL's URLByDeletingPathExtension() |
080 | set ocidSaveFilePathURL to ocidBaseFileURL's URLByAppendingPathExtension:"plist" |
081 | ###保存 |
082 | set boolWritetoUrlArray to ocidPlistEditData's writeToURL:(ocidSaveFilePathURL) options:0 |error| :(reference) |
083 | |
084 | return "処理終了" |
AppleScriptで生成しました |
| 固定リンク
[Json]ROOTがDict形式のJSONの操作
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | #com.cocolog-nifty.quicktimer.icefloe |
005 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
006 | use AppleScript version "2.8" |
007 | use framework "Foundation" |
008 | use framework "AppKit" |
009 | use framework "UniformTypeIdentifiers" |
010 | use scripting additions |
011 | property refMe : a reference to current application |
012 | property ocidChosenFilePathURL : missing value |
013 | |
014 | |
015 | ################## |
016 | #ファイル選択ダイアログ |
017 | on appChooseFile:(ocidArgDirPathURL) |
018 | set ocidOpenPanel to refMe's NSOpenPanel's openPanel() |
019 | ocidOpenPanel's setDirectoryURL:(ocidArgDirPathURL) |
020 | ocidOpenPanel's setCanChooseFiles:(true) |
021 | ocidOpenPanel's setCanChooseDirectories:(false) |
022 | ocidOpenPanel's setAllowsMultipleSelection:(false) |
023 | ocidOpenPanel's setAccessoryViewDisclosed:(true) |
024 | ocidOpenPanel's setTitle:"ファイルを選んでください" |
025 | ocidOpenPanel's setPrompt:"実行" |
026 | ocidOpenPanel's setMessage:"JSONファイルを選んでください" |
027 | ocidOpenPanel's setShowsTagField:(true) |
028 | ocidOpenPanel's setResolvesAliases:(false) |
029 | ocidOpenPanel's setShowsHiddenFiles:(true) |
030 | ocidOpenPanel's setExtensionHidden:(false) |
031 | ocidOpenPanel's setCanCreateDirectories:(true) |
032 | ocidOpenPanel's setCanDownloadUbiquitousContents:(true) |
033 | ocidOpenPanel's setCanResolveUbiquitousConflicts:(true) |
034 | ocidOpenPanel's setCanSelectHiddenExtension:(true) |
035 | ocidOpenPanel's setTreatsFilePackagesAsDirectories:(true) |
036 | #対象のUTIを限定する |
037 | set listUTI to {"public.json"} as list |
038 | set ocidUTIarray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0) |
039 | repeat with itemUTI in listUTI |
040 | set ocidItemUTType to (refMe's UTType's typeWithIdentifier:(itemUTI)) |
041 | (ocidUTIarray's addObject:(ocidItemUTType)) |
042 | end repeat |
043 | #UTTypeを限定項目としてセット |
044 | ocidOpenPanel's setAllowedContentTypes:(ocidUTIarray) |
045 | #実行 |
046 | set returnCode to ocidOpenPanel's runModal() |
047 | #キャンセルをmissing value |
048 | if returnCode = (refMe's NSModalResponseCancel) then |
049 | log "キャンセル" |
050 | error number -128 |
051 | else if returnCode = (refMe's NSModalResponseOK) then |
052 | log "OK" |
053 | set my ocidChosenFilePathURL to ocidOpenPanel's |URL|() |
054 | return |
055 | end if |
056 | |
057 | end appChooseFile: |
058 | ################## |
059 | # path to me |
060 | set aliasPathToMe to (path to me) as alias |
061 | set strPathToMe to (POSIX path of aliasPathToMe) as text |
062 | set ocidPathToMeStr to refMe's NSString's stringWithString:(strPathToMe) |
063 | set ocidPathToMe to ocidPathToMeStr's stringByStandardizingPath() |
064 | set ocidPathToMeURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidPathToMe) isDirectory:(false) |
065 | set ocidContainerDirPathURL to ocidPathToMeURL's URLByDeletingLastPathComponent() |
066 | |
067 | ################## |
068 | #ダイアログ実行 |
069 | my performSelectorOnMainThread:("appChooseFile:") withObject:(ocidContainerDirPathURL) waitUntilDone:(true) |
070 | #ダイアログの戻り値 |
071 | set ocidFilePathURL to ocidChosenFilePathURL |
072 | |
073 | ################## |
074 | # ここから本処理 |
075 | ################## |
076 | #保存先 |
077 | set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension() |
078 | set ocidSaveFilePathURL to ocidBaseFilePathURL's URLByAppendingPathExtension:("plist") |
079 | |
080 | ################## |
081 | #NSDATA |
082 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
083 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error| :(reference) |
084 | set ocidReadData to (item 1 of listResponse) |
085 | |
086 | ################## |
087 | #JSONシリアル |
088 | set appJsonSerial to (refMe's NSJSONSerialization) |
089 | set ocidOption to (refMe's NSJSONReadingMutableContainers) |
090 | set listResponse to appJsonSerial's JSONObjectWithData:(ocidReadData) options:(ocidOption) |error| :(reference) |
091 | set ocidJsonDict to (item 1 of listResponse) |
092 | |
093 | ################## |
094 | #本処理 |
095 | # レコード=辞書構造の子構造に |
096 | # リスト=配列構造のデータ |
097 | # 操作するならここ |
098 | set ocidFontsArray to ocidJsonDict's objectForKey:("Fonts") |
099 | repeat with itemArray in ocidFontsArray |
100 | log (itemArray's valueForKey:("f")) as text |
101 | end repeat |
102 | |
103 | ################## |
104 | #PLIST |
105 | set ocidFormat to (refMe's NSPropertyListXMLFormat_v1_0) |
106 | set listResponse to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidJsonDict) format:(ocidFormat) options:0 |error| :(reference) |
107 | set ocidSaveData to (item 1 of listResponse) |
108 | |
109 | ################## |
110 | #保存 |
111 | set ocidOption to (refMe's NSDataWritingAtomic) |
112 | set listDone to ocidSaveData's writeToURL:(ocidSaveFilePathURL) options:(ocidOption) |error| :(reference) |
AppleScriptで生成しました |
| 固定リンク
より以前の記事一覧
- [Json]ROOTがArray形式のJSONの操作 2024.12.08
- 市区町村番号取得 API利用版 ダイアログ戻り 2024.10.14
- 市区町村番号取得 API利用版 HTML出力 2024.10.14
- [Json]PlistをJsonに変換する(NSTaggedDate対策入り) 2024.03.25
- [Json] JSONの操作 自分まとめ 2024.02.01
- [ip.guide]IPアドレス取得(IPアドレスからの位置情報付き) 2023.11.26
- [valueForKeyPath]非圧縮ZIPを解凍して内部のデータから値を取得する(curveファイルにアートボード縦横サイズを付与する) 2023.10.20
- [JSON]為替計算 2023.10.02
- [JSON]市区町村コード取得 2023.09.25
- [JSON]JSONの取扱 その2(rootがArray形式の場合) 2023.09.23
- [JSON]JSONの取扱 その1(rootがDict形式の場合) 2023.09.23
- [Bash]JSONから値を取得する(plist変換) 2023.08.26
- [AppStore]iPhoneアプリのBundleId(バンドルID)を取得する(改良) 2023.08.06
- [Stocks]為替レートを取得するJSON 2023.07.31
- [musicbrainz]アーティスト名+曲名から、アルバム名を取得する(JSON) 2023.06.15
- [musicbrainz]アーティスト名から、musicbrainzのアーティストIDを取得する(JSON) 2023.06.15
- 祭日の取得(github版) 2023.06.10
- [JSON]PLISTファイルをJSONに変換する 2023.06.02
- [JSON]JSONファイルをPLISTに変換する 2023.06.02
- [JSON]JSONデータをテキスト形式に戻す 2023.03.08
- [JSON]POSTでデータを取得する 2023.03.08
- [JSON]レコードをJSONにする 2023.03.07
- [JSON]為替レートを取得する 2022.11.14
- [Excel]カレンダー生成(曜日・祝日入り)GoogleAPI 2022.11.07
- [Json]祝祭日の取得 GoogleAPI版 2022.11.07
- [Json]祝祭日の取得 2022.11.04
- [exiftool]JSONデータをPLISTに変換する 2022.10.06
- [InDesign] インデザイン用 ルビ用タグ付きテキスト(YahooAPI利用) 2022.05.31
- [json]QRコードのイメージファイルをデコードする 2022.05.18
- [Illustrator用] 割注サポート文書作成 2022.04.25
- [Json]YahooAPIを使ってテキストにrubyタグを付与 2022.04.20
- [JSON]テキストエディット yahooのAPIを使ってふりがなを付与する 2022.04.20
- [JSON]テキストエディット GooのAPIを使ってふりがなを付与する 2022.04.20
- [Json]ApplescriptでJsonの取り扱い 2022.04.19
- [Json]元データをrecordに変換する方法 2022.04.19
- [Json]JSON Helper 2022.04.19
- [Json] plist化して処理する 2022.04.19
- [Json] Record化して処理する 2022.04.19
- [Json]List化して処理する 2022.04.19
その他のカテゴリー
Accessibility Acrobat Acrobat 2020 Acrobat 2024 Acrobat AddOn Acrobat Annotation Acrobat AppleScript Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat GentechAI Acrobat JS Acrobat JS Word Search Acrobat Maintenance Acrobat Manifest Acrobat Menu Acrobat Merge Acrobat Open Acrobat PDFPage Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat Print Acrobat Python Acrobat Reader Acrobat Reader Localized Acrobat Reference Acrobat Registered Products Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat URL List Mac Acrobat URL List Windows Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin ConfigCode Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin NetWork Admin Permission Admin Pkg Admin Power Management Admin Printer Admin Printer Basic Admin Printer Custompapers Admin SetUp Admin SMB Admin softwareupdate Admin Support Admin System Information Admin TCC Admin Tools Admin Umask Admin Users Admin Volumes Admin XProtect Adobe Adobe AUSST Adobe Bridge Adobe Documents Adobe FDKO Adobe Fonts Adobe Reference Adobe RemoteUpdateManager Adobe Sap Code AppKit Apple AppleScript AppleScript Duplicate AppleScript entire contents AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Video Applications AppStore Archive Archive Keka Attributes Automator BackUp Barcode Barcode Decode Barcode QR Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome Chromedriver CIImage CityCode CloudStorage Color Color NSColor Color NSColorList com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Desktop Position Device Diff Disk do shell script Dock Dock Launchpad DropBox Droplet eMail Encode % Encode Decode Encode HTML Entity Encode UTF8 Error EXIFData exiftool ffmpeg File File Name Finder Finder Window Firefox Folder FolderAction Font List FontCollections Fonts Fonts Asset_Font Fonts ATS Fonts Emoji Fonts Maintenance Fonts Morisawa Fonts Python Fonts Variable Foxit GIF github Guide HTML Icon Icon Assets.car Illustrator Image Events ImageOptim Input Dictionary iPhone iWork Javascript Jedit Ω Json Label Language Link locationd lsappinfo m3u8 Mail Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Microsoft Fonts Microsoft Office Microsoft Office Link Microsoft OneDrive Microsoft Teams Mouse Music Node Notes NSArray NSArray Sort NSAttributedString NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSGraphicsContext Crop NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMetadataItem NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSet NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSUbiquitous NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth PDF PDF Image2PDF PDF MakePDF PDF nUP PDF Pymupdf PDF Pypdf PDFContext PDFDisplayBox PDFImageRep PDFKit PDFKit Annotation PDFKit AnnotationWidget PDFKit DocumentPermissions PDFKit OCR PDFKit Outline PDFKit Start PDFPage PDFPage Rotation PDFView perl Photoshop PlistBuddy pluginkit plutil postalcode PostScript PowerShell prefPane Preview Python Python eyed3 Python pip QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver Script Editor Script Menu SF Symbols character id SF Symbols Entity Shortcuts Shortcuts Events sips Skype Slack Sound Spotlight sqlite StandardAdditions StationSearch Subtitles LRC Subtitles SRT Subtitles VTT Swift swiftDialog System Events System Settings TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom Weather webarchive webp Wifi Windows XML XML EPUB XML HTML XML LSSharedFileList XML LSSharedFileList sfl2 XML LSSharedFileList sfl3 XML objectsForXQuery XML OPML XML Plist XML Plist System Events XML RSS XML savedSearch XML SVG XML TTML XML webloc XML xmllint XML XMP YouTube Zero Padding zoom