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
710
Boost your App Dev using Sketch
griffin_stewie
0
300
Take a peep at .app
griffin_stewie
0
440
Lightweight Markup Language to PDF
griffin_stewie
1
590
ドキュメント作成どうしてる?
griffin_stewie
0
600
Pitfalls of PhotoKit
griffin_stewie
0
260
Talk about "clg" color list generator.
griffin_stewie
1
450
Tips for Apple Watch.
griffin_stewie
0
810
Other Decks in Technology
See All in Technology
時間がないなら、つくればいい 〜数十人規模のチームが自律性を発揮するために試しているいくつかのこと〜
kakehashi
PRO
23
5.7k
20 Years of Domain-Driven Design: What I’ve Learned About DDD
ewolff
1
370
newmo の創業を支える Software Architecture と Platform Engineering
110y
5
540
RubyKaigi NOC 近況 2025
sorah
3
1k
[新卒向け研修資料] テスト文字列に「うんこ」と入れるな(2025年版)
infiniteloop_inc
13
42k
Sleep-time Compute: LLM推論コスト削減のための事前推論
sergicalsix
1
140
テストコードにはテストの意図を込めよう(2025年版) #retechtalk / Put the intent of the test 2025
nihonbuson
PRO
9
1.7k
経済メディア編集部の実務に小さく刺さるAI / small-ai-with-editorial
nkzn
2
420
AIエージェントのオブザーバビリティについて
yunosukey
0
280
AWSを利用する上で知っておきたい名前解決の話
nagisa53
6
830
Software Architecture in an AI-Driven World
atty303
42
16k
Асинхронная коммуникация в Go: от понятного к душному. Дима Некрасов, Otello, 2ГИС
lamodatech
0
2.2k
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.4k
We Have a Design System, Now What?
morganepeng
52
7.6k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
The Language of Interfaces
destraynor
158
25k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
570
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
24
2.7k
Building Adaptive Systems
keathley
41
2.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
800
Mobile First: as difficult as doing things right
swwweet
223
9.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
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༵