Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JSON をそこそこ見やすくする CUI ツールを Objective-C で作ったときの話
Search
griffin-stewie
June 01, 2013
Technology
1
570
JSON をそこそこ見やすくする CUI ツールを Objective-C で作ったときの話
第50回 Cocoa勉強会関西 - iOS/Macアプリ開発勉強会
発表資料
griffin-stewie
June 01, 2013
Tweet
Share
More Decks by griffin-stewie
See All by griffin-stewie
How I develop a Sketch Native Plugin
griffin_stewie
0
670
Boost your App Dev using Sketch
griffin_stewie
0
290
Take a peep at .app
griffin_stewie
0
430
Lightweight Markup Language to PDF
griffin_stewie
1
560
ドキュメント作成どうしてる?
griffin_stewie
0
580
Pitfalls of PhotoKit
griffin_stewie
0
250
Talk about "clg" color list generator.
griffin_stewie
1
440
Tips for Apple Watch.
griffin_stewie
0
780
Other Decks in Technology
See All in Technology
5分でわかるDuckDB
chanyou0311
10
3.2k
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
150
Qiita埋め込み用スライド
naoki_0531
0
860
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
170
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
270
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
440
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
540
Postman と API セキュリティ / Postman and API Security
yokawasa
0
200
AWS re:Invent 2024 ふりかえり
kongmingstrap
0
130
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
260
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
510
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
Producing Creativity
orderedlist
PRO
341
39k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Embracing the Ebb and Flow
colly
84
4.5k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
Become a Pro
speakerdeck
PRO
26
5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Unsuck your backbone
ammeep
669
57k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Transcript
JSON Λͦͦ͜͜ݟ͘͢͢Δ CUI πʔϧΛ࡞ͬͨͱ͖ͷ @griffin_stewie 136݄1༵
ࣗݾհ •େࡕͰ iOS ΞϓϦ։ൃͷࣄΛ͍ͯ͠ ·͢ •Cocoa ྺ 5 ఔ •SafariGestures
ͱ͔ SafariTabMemento ͱ ͔ Safari ͷ SIMBL ϓϥάΠϯΛ @canberland ͱҰॹʹ࡞ͬͯ·ͨ͠ɻ 136݄1༵
ຊ 136݄1༵
CUI ͱ 136݄1༵
•Character •User •Interface 136݄1༵
ࠇ͍ը໘ʹढจ 136݄1༵
ී௨ LL ܥݴޠͰαΫοͱ࡞ Δײ͡ 136݄1༵
Ͱɺ 136݄1༵
•Ruby Ҏ֎͞Θͬͨ͜ͱͳ͍ •֎෦ϥΠϒϥϦΛಉࠝͯ͠Ͱ͖ Δͷʁ •ௐΔͷΊΜͲ͍͘͞ •͋͊ ΊΜͲ͍͘͞ 136݄1༵
Ͱɺࣗʹͱͬͯͷ CUI 136݄1༵
•Cocoa Ͱ •U·͍͜ͱΕ •I͍Μ͡ΌͶʁ 136݄1༵
ͯͳΘ͚Ͱ Objective-C Ͱ࡞ͬ ͨͱ͖ͷ 136݄1༵
ಈػ 136݄1༵
JSON ͕ݟʹ͔͔ͬͨ͘Β 136݄1༵
136݄1༵
python -m json.tool 136݄1༵
136݄1༵
ຊޠ͕ಡΊͳ͍ 136݄1༵
࡞ͬͨͷ͕ 136݄1༵
jsonpp http://griffin-stewie.github.io/jsonpp/ 136݄1༵
136݄1༵
ຊޠ͕ಡΊͨ 136݄1༵
•ϩʔΧϧͷ JSON ϑΝΠϧΛಡΈࠐΜ ͩΓ •http Ͱͱ͖ͬͯͨΓ •Key Λιʔτͨ͠Γ •ιʔτ͢Δͱ͖ʹࣈͱͯ͠ѻͬͨΓ •ϑΝΠϧʹอଘͨ͠Γ
136݄1༵
ͬͨ͜ͱ 136݄1༵
ίϚϯυϥΠϯҾͷॲཧͬͯ Ͳ͏Μͷʁ 136݄1༵
•DDCli ͍ͬͯ͏ϥΠϒϥϦΛͬͨ •appledoc ʹΘΕ͍ͯΔ 136݄1༵
•DDCli ͷσϦήʔτϝιουΛ2࣮ͭ͢Δ •1ͭ Φϓγϣϯͷఆٛ༻ • ड͚͚͍ͨίϚϯυϥΠϯΦϓγϣϯΛߏମͷ ྻͱͯ͠ఆٛ •͏1ͭ CUI ΞϓϦͱͯ͠ͷΤϯτϦϙΠϯτ
• ίϚϯυϥΠϯΦϓγϣϯσϦήʔτΦϒδΣΫ τʹ KVC ܦ༝ͰηοτࡁΈ • ͦͷ΄͔ͷҾ͕͞ΕΔ 136݄1༵
1. main.m ͷมߋ int main(int argc, const char * argv[])
{ int result = 0; @autoreleasepool { result = DDCliAppRunWithClass( [CSJSONPrettyPrint class]); } return result; } 136݄1༵
2. Delegate ͷ࣮ •- (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser *)optionParser •- (void)application:(DDCliApplication
*)app runWithArguments:(NSArray *)arguments 136݄1༵
•- (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser *)optionParser •application:(DDCliApplication *)app runWithArguments:(NSArray *)arguments ͷલʹݺ
ΕΔ •DDGetoptOption ߏମΛ࡞͠ɺσϦήʔτϝ ιουͰ͞Εͨ DDGetoptLongParser Πϯελ ϯεʹ addOptionsFromTable: Ͱ͢ 136݄1༵
DDGetoptOption - (void)application:(DDCliApplication *)app willParseOptions:(DDGetoptLongParser *)optionsParser; { DDGetoptOption optionTable[] =
{ // Long Short Argument options {@"version", 'v', DDGetoptNoArgument}, {@"help", 'h', DDGetoptNoArgument}, {@"output", 'o', DDGetoptRequiredArgument}, {@"filter-key", 'k', DDGetoptRequiredArgument}, {nil, 0, 0}, }; [optionsParser addOptionsFromTable: optionTable]; } 136݄1༵
DDGetoptOption •Long Φϓγϣϯͷ໊শ (--version ͷ "--" Λআ͍ ͨจࣈྻ) •short Φϓγϣϯͷ໊শ
•Φϓγϣϯ͕ҾΛͱΔ͔ͱΒͳ͍͔ͷࢦఆ 136݄1༵
•- (void)application:(DDCliApplication *)app runWithArguments:(NSArray *)arguments •arguments ʹઃఆͨ͠ΦϓγϣϯҎ֎ͷίϚ ϯυϥΠϯҾ͕ೖ͍ͬͯΔ 136݄1༵
ΦϓγϣϯҾͷରԠ •main ؔͰࢦఆͨ͠Ϋϥεʹରͯ͠ KVC Λͬ ͯΛಥͬࠐΜͰ͘ΕΔ • ϓϩύςΟ໊ Long Φϓγϣϯͱಉ໊͡শ
• ܕ NSString 136݄1༵
JSON ͷ Pretty-Print Ͳ͏ͨ͠ͷʁ 136݄1༵
SBJSON ʹؙ͛ 136݄1༵
Debug ΊΜͲͦ͏ 136݄1༵
໘ 136݄1༵
•ͰɺXcode ʹ Run ͨ͠ͱ͖ʹҙ ͷҾΛͤΔΈ͕͋ΔΑ •ෳఆٛͰ͖ͯνΣοΫϘοΫεͰ On/Off Մ •GUI ΞϓϦͱେͯ͠มΘΒͳ͍खؒ
136݄1༵
Xcode ศར 136݄1༵
manpage ࡞ͬͨΑ 136݄1༵
manpage ͷه๏ҙຯෆ໌ 136݄1༵
Կ͜Εʁ จࣈԽ͚ʁ 136݄1༵
͜Μͳͷه๏ͳΜ͔ษڧ ͯ͠ΒΜͶ͐ 136݄1༵
Pandoc Ͱੜͨ͠ 136݄1༵
Pandoc ͬͯʁ •Pandoc a universal document converter • ଟ༷ͳςΩετϑΥʔϚοτΛผͷϑΥʔϚοτʹม •
ରԠϑΥʔϚοτྫ • markdown • reStructuredText • textile • MediaWiki • ODT • docx • ͦͷଞ͍Ζ͍Ζ 136݄1༵
markdown Ͱॻ͍ͯมͨ͠ 136݄1༵
Πϯετʔϥʔ༻ҙͨ͠ 136݄1༵
ࠓͷ Xcode ʹ PackageManager ͕ಉࠝ͞Εͯ ͳ͍ 136݄1༵
Developer Center ͷ Auxiliary Tools for Xcode ͷதʹ͋ͬͨ 136݄1༵
͍ํ؆୯ 136݄1༵
άάΕʂ 136݄1༵
ͱ͍͏͜ͱͰ jsonpp Ͱ͖ͨΑ 136݄1༵
ͰͶ 136݄1༵
jq jq is a lightweight and flexible command-line JSON processor.
136݄1༵
jq •http://stedolan.github.io/jq/ •C Ͱॻ͔Εͨ JSON Λݟͯ͘͘͢͠ΕΔࢠ •ڧྗ •XPath తʹతͷσʔλ͚ͩநग़ͨ͠Γ •map
ͱ͔ select ͱ͔ؔతͳϑΟϧλϦϯά ग़དྷΔ 136݄1༵
͜Μͳͷ͕ 136݄1༵
৭͕͍ͭͨΓ 136݄1༵
ཉ͍͠ͷ͚ͩϑΟϧλͨ͠Γ 136݄1༵
jq Ϛδ Φψψϝ 136݄1༵
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ 136݄1༵