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
640
Boost your App Dev using Sketch
griffin_stewie
0
290
Take a peep at .app
griffin_stewie
0
420
Lightweight Markup Language to PDF
griffin_stewie
1
530
ドキュメント作成どうしてる?
griffin_stewie
0
550
Pitfalls of PhotoKit
griffin_stewie
0
240
Talk about "clg" color list generator.
griffin_stewie
1
420
Tips for Apple Watch.
griffin_stewie
0
770
Other Decks in Technology
See All in Technology
Autonomous Database Cloud 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
15
40k
リクルート新人研修2024 テキスト生成AI活用
recruitengineers
PRO
10
480
スーパーマリオRPGのリメイク版の変更点からみるUX
nishiharatsubasa
1
290
React Aria で実現する次世代のアクセシビリティ
ryo_manba
4
950
Cloud Service Mesh への期待が止まらない!!
phaya72
2
180
エンジニア向け会社紹介資料
caddi_eng
15
250k
[RSJ24] Task Success Prediction for Open-Vocabulary Manipulation Based on Multi-Level Aligned Representations
keio_smilab
PRO
0
230
音声AIエージェントの世界とRetell AI入門 / Introduction to the World of Voice AI Agents and Retell AI
rkaga
4
840
四国クラウドお遍路 2024 in 高知 エンディング
yukataoka
0
160
Oracle Database 23ai 新機能 #3 Oracle Globally Distributed Database(GDD)
oracle4engineer
PRO
1
170
20分で分かるIAM全機能 (拡大版) / 20240903-jawsug-yokohama-iam
opelab
3
130
Swift Testingのconfirmationを コードリーディング/Dive into Swift Testing confirmation
laprasdrum
1
100
Featured
See All Featured
Bash Introduction
62gerente
608
210k
Side Projects
sachag
451
42k
Unsuck your backbone
ammeep
667
57k
Embracing the Ebb and Flow
colly
83
4.4k
Agile that works and the tools we love
rasmusluckow
327
20k
The Language of Interfaces
destraynor
153
23k
Build The Right Thing And Hit Your Dates
maggiecrowley
30
2.2k
Code Reviewing Like a Champion
maltzj
518
39k
The Pragmatic Product Professional
lauravandoore
30
6.2k
How STYLIGHT went responsive
nonsquared
93
5.1k
Typedesign – Prime Four
hannesfritz
39
2.3k
Thoughts on Productivity
jonyablonski
66
4.2k
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༵