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
1
1.7k
jq at the Shortcuts
Presented @ potatotips#80
cockscomb
December 22, 2022
Tweet
Share
More Decks by cockscomb
See All by cockscomb
GraphQL放談
cockscomb
4
1.9k
GraphQL Highway
cockscomb
28
8.2k
吉田を支える技術
cockscomb
0
2.1k
コーポレートサイトを静的化してAmplify Consoleにデプロイする
cockscomb
0
3.3k
ユーザインターフェイスと非同期処理
cockscomb
5
1.8k
GUIアプリケーションの構造と設計
cockscomb
10
10k
イカリング2におけるシングルページアプリケーション
cockscomb
2
7.4k
あなたの知らない UIKit の世界 — UITableView に UITextView を置きたい
cockscomb
1
7.3k
iOSアプリエンジニアのためのAndroidアプリ開発
cockscomb
7
1.8k
Other Decks in Programming
See All in Programming
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
4
2.8k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
120
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
14
3.8k
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
110
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
950
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
220
ActiveRecordの力でDBのメタデータを迅速に解析する
lnit
5
2.2k
推し活の ハイトラフィックに立ち向かう Railsとアーキテクチャ - Kaigi on Rails 2024
falcon8823
6
1.7k
Prompt Engineering for Developers @ AWS Community Day Adria 2024
slobodan
0
120
offers_20241022_imakiire.pdf
imakurusu
2
310
C#/.NETのこれまでのふりかえり
tomokusaba
1
140
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
110
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
5
140
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
Building an army of robots
kneath
302
42k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
GitHub's CSS Performance
jonrohan
1030
460k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
328
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9k
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