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
680
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
570
ドキュメント作成どうしてる?
griffin_stewie
0
590
Pitfalls of PhotoKit
griffin_stewie
0
250
Talk about "clg" color list generator.
griffin_stewie
1
440
Tips for Apple Watch.
griffin_stewie
0
790
Other Decks in Technology
See All in Technology
トラブルシュートを楽しもう (wakamonog meeting 15)
recuraki
5
1.1k
クロスアカウントな RDS Snapshot Export による カジュアルなデータ集約の仕組み / 202501-finatext-technight-lt
wa6sn
1
120
RevOpsへ至る道 データ活用による事業革新への挑戦 / path-to-revops
pei0804
2
560
SREとしてスタッフエンジニアを目指す / SRE Kaigi 2025
tjun
15
5.1k
dbtを中心にして組織のアジリティとガバナンスのトレードオンを考えてみた
gappy50
2
410
レイクハウスとはなんだったのか?
akuwano
14
1.7k
SREKaigi.pdf
_awache
2
3.2k
AIアプリケーション開発でAzure AI Searchを使いこなすためには
isidaitc
1
280
プロダクト開発、インフラ、コーポレート、そしてAIとの共通言語としての Terraform / Terraform as a Common Language for Product Development, Infrastructure, Corporate Engineering, and AI
yuyatakeyama
6
1.4k
大学教員が押さえておくべき生成 AI の基礎と活用例〜より効率的な教育のために〜
soh9834
1
170
CNAPPから考えるAWSガバナンスの実践と最適化
yuobayashi
4
490
Women in Agile
kawaguti
PRO
2
140
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
47
7.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Bash Introduction
62gerente
610
210k
Speed Design
sergeychernyshev
25
750
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
Producing Creativity
orderedlist
PRO
343
39k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Designing for humans not robots
tammielis
250
25k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Typedesign – Prime Four
hannesfritz
40
2.5k
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༵