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
jq at the Shortcuts
Search
cockscomb
December 22, 2022
Programming
2.1k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
jq at the Shortcuts
Presented @ potatotips#80
cockscomb
December 22, 2022
More Decks by cockscomb
See All by cockscomb
はてなアカウント基盤 State of the Union
cockscomb
1
1.4k
GraphQL放談
cockscomb
4
2.1k
GraphQL Highway
cockscomb
28
8.8k
吉田を支える技術
cockscomb
0
2.5k
コーポレートサイトを静的化してAmplify Consoleにデプロイする
cockscomb
0
3.5k
ユーザインターフェイスと非同期処理
cockscomb
5
2.1k
GUIアプリケーションの構造と設計
cockscomb
10
10k
イカリング2におけるシングルページアプリケーション
cockscomb
2
7.7k
あなたの知らない UIKit の世界 — UITableView に UITextView を置きたい
cockscomb
1
7.6k
Other Decks in Programming
See All in Programming
Foundation Models frameworkで画像分析
ryodeveloper
1
250
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
130
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
480
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
180
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
3.2k
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
290
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
200
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
17k
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
290
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
210
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
160
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
150
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Automating Front-end Workflow
addyosmani
1370
210k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
370
A Modern Web Designer's Workflow
chriscoyier
698
190k
sira's awesome portfolio website redesign presentation
elsirapls
0
310
Building the Perfect Custom Keyboard
takai
2
820
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Amusing Abliteration
ianozsvald
1
240
Code Reviewing Like a Champion
maltzj
528
40k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
350
Transcript
.app jq
id:cockscomb
jq
jq stedolan.github.io/jq/ $ echo '{"foo": "bar"}' | jq '.foo' "bar"
gh Scripting with GitHub CLI | The GitHub Blog $
gh api ... -- jq '.[].login' # = > "user1" # = > "user2" # = > ...
jq JSON
.app
URL
None
jq
Swift jq
gojq itchyny/gojq: Pure Go implementation of jq
golang.org/x/mobile
package binding import ( "github.com/itchyny/gojq" _ "golang.org/x/mobile/bind" ) type Query
struct { query *gojq.Query } func NewQuery(src string) (*Query, error) { query, err := gojq.Parse(src) if err != nil { return nil, err } return &Query{query: query}, nil } func (q *Query) Run(input []byte) (*Iterator, error) { ... }
$ gomobile bind \ -target=ios,iossimulator,macos,maccatalyst \ -iosversion 14 \ -prefix
GOJQ \ -o Frameworks/GOJQBinding.xcframework \ github.com/cockscomb/swift-gojq/binding
import Foundation open class GOJQBindingIterator : NSObject, goSeqRefInterface { public
init() open func next() throws -> Data } open class GOJQBindingQuery : NSObject, goSeqRefInterface { public init?(_ src: String?) open func run(_ input: Data?) throws -> GOJQBindingIterator } public func GOJQBindingNewQuery(_ src: String?, _ error: NSErrorPointer) -> GOJQBindingQuery?
import GOJQBinding enum QueryError: Error { case unknown } public
struct Query { private let binding: GOJQBindingQuery public init(_ query: String) throws { var error: NSError? guard let binding = GOJQBindingNewQuery(query, &error) else { throw error ?? QueryError.unknown } self.binding = binding } public func run(_ input: Data) throws -> AsyncThrowingStream<Data, any Error> { ... } }
None
// swift-tools-version: 5.7 import PackageDescription let package = Package( name:
"SwiftGoJq", platforms: [ .macOS(.v13), .macCatalyst(.v14), .iOS(.v14) ], products: [ .library(name: “SwiftGoJq”, targets: ["SwiftGoJq"]), ], dependencies: [], targets: [ .binaryTarget( name: "GOJQBinding", url: "https://github.com/cockscomb/swift-gojq/releases/download/0.1.0/ GOJQBinding.xcframework.zip", checksum: "1c45710de17fb7020dcfc75105344729725c5e3875e7058e98790e5f4e178162"), .target( name: "SwiftGoJq", dependencies: [ "GOJQBinding", ]), ] )
cockscomb/swift-gojq
None
import AppIntents import AsyncAlgorithms import SwiftGoJq struct JQIntent: AppIntent {
static var title: LocalizedStringResource = "jq" @Parameter(title: "JSON") var input: String @Parameter(title: "Query") var query: String static var parameterSummary: some ParameterSummary { Summary("\(\.$input) | jq '\(\.$query)'") } func perform() async throws -> some IntentResult { let jq = try Query(query) let results = try jq.run(input) let array = try await Array(results) return .result(value: array) } }
None
None
WEB+DB PRESS vol. 1 3 2 iOS 1 6 12/24
3 id:cockscomb id:yutailang 01 19 id:kouki_dan