- अब समर्थित नहीं रहे
--argfileoption औरleaf_paths,recurse_downfilter हटा दिए गए हैं - Docker image अब Docker Hub की जगह
ghcr.io/jqlang/jqपर उपलब्ध है - रिलीज़ build targets में Linux, macOS, Windows और Docker की कई architectures को स्पष्ट किया गया है
--raw-output0जोड़ा गया है, जिससे outputs के बीच NUL byte डाला जा सकता है, और NUL शामिल करने वाले string output पर error हैंडलिंग होती है- Windows पर
--binary/-boption जोड़ा गया है, जिससे\r\nकी जगह\nline endings आउटपुट किए जा सकते हैं JQ_COLORSसे object key colors सेट किए जा सकते हैं, औरNO_COLORenvironment variable का सम्मान करते हुए color output बंद किया जा सकता है--exit-code/-eoption के exit code से जुड़ी समस्या ठीक की गई है: आखिरी output value truthy हो तो 0,falseयाnullहो तो 1, और कोई output न हो तो 4 लौटाया जाता है- number literals की precision preservation के लिए decimal number literals का उपयोग किया गया है; comparison operations precision का सम्मान करती हैं, लेकिन arithmetic operations में truncation हो सकता है
- नए built-in functions
pick(stream),debug(msgs),scan($re; $flags),absजोड़े गए हैं ifstatement मेंelsebranch को छोड़ा जा सकता है, और छोड़ा गयाelse.व्यवहार की तरह माना जाएगाhaltऔरhalt_errorअब अगले input पर आगे बढ़ने के बजाय तुरंत terminate करते हैं- कुछ platforms पर बड़े numbers की वजह से गलत JSON output बनने की समस्या, libjq और threads के साथ segmentation fault, और
--jsonargके assert crash को ठीक किया गया है - CI, scan build, release, और website build अब GitHub Actions का उपयोग करते हैं, और OSS-Fuzz जोड़ा गया है
1 टिप्पणियां
Hacker News की रायें
JQ शानदार है, इसलिए मुझे यह सचमुच पसंद है
हमने अपने product (JVM और browser-आधारित Kafka tool) में Clojure में JQ का एक subset implement किया, ताकि user data को transform/filter कर सकें। यह मेरे लिखे code में सबसे मज़ेदार कामों में से एक था, और चूंकि मुझे grammar लिखना खुद पसंद है, इसलिए Instaparse का भी बहुत आभार: https://github.com/Engelberg/instaparse
implement करते समय पता चला कि JQ LISP-2 है, और सिर्फ syntax देखकर ऐसा नहीं लगता था, इसलिए हैरानी हुई: https://github.com/jqlang/jq/wiki/jq-Language-Description#:~...
लेकिन इसकी non-intuitive query syntax, हर छोटे step पर search करने की ज़रूरत, और फिर result का ऐसा मंत्र जैसा दिखना जिसे jq expert न हो तो समझना मुश्किल है—ये सब खटकता है। htmx या tailwind की तरह strings के अंदर दबे हुए DSLs को लेकर मुझे instinctively resistance होता है
फिर भी मानता हूँ कि यह अच्छी तरह बनाया गया software है, और कभी-कभी इससे बेहतर विकल्प नहीं होता। JSON को bash में handle करते समय sed/awk/cut वाले monstrosity की तुलना में यह सबसे कम खराब विकल्प भी है। बस scripts के बीच में हमेशा किसी unreadable string की तरह फंसी jq commands, regex की तरह, code में उन चीज़ों में आती हैं जिन्हें मैं देखना नहीं चाहता। alternative के तौर पर मैंने heredoc के अंदर inline Python को pipe करके भी देखा है, लेकिन वह भी jq scripts जितना ही messy हो जाता है
examples में "Jq parser (partially working)" चुनकर "Parse" दबाएँ, तो "Input source" के source के लिए parser tree देख सकते हैं। feedback हमेशा welcome है
jq ज्यादातर cases को simple बना देता है (असल में JSON dot notation), और long tail वाले complex cases को भी संभव कर देता है
मुझे jq पसंद है, लेकिन JMESPath (खासकर AWS CLI के साथ), yq (tomlq और xq सहित), और dasel भी इस्तेमाल करता हूँ। hclq का लगभग dead होना अफसोसजनक है
https://jmespath.org/
https://kislyuk.github.io/yq/
https://github.com/TomWright/dasel
https://hclq.sh/
मैं कई सालों से
jqइस्तेमाल कर रहा हूँ और जो चाहिए होता है उसे किसी न किसी तरह compose कर लेता हूँ, लेकिन आज तक यह intuitive नहीं लगा। थोड़ा भी complex होते ही docs को काफी देर पढ़े बिना solution तक पहुँचना मुश्किल है, और काश इसे और आसानी से इस्तेमाल किया जा सकताशुरुआत में syntax सीखते समय मदद मिली थी, और आज भी अजीब syntax में अटकने पर फिर वहीं जाता हूँ
इसका सबसे बड़ा use case CSV, TOML, XML जैसी चीज़ों को JSON में convert करके jq में pipe करना है: https://github.com/sentriz/rsl
https://github.com/kellyjonbrazil/jello
https://github.com/wwkimball/yamlpath
XPath से inspired होने के कारण यह पूरी तरह नए DSL से ज्यादा familiar लगता है, और मेरे हिसाब से इसका core feature recursive key lookup है।
people..addressलिखने पर JSON में कहीं भी "people" के नीचे आने वाली हर "address" key ढूँढ देता है। JSON के लिए parsing languages में यह मेरा favorite है, और मैंने JSON datasets parse करने में इसे इस्तेमाल करने का तरीका बताने वाला article भी लिखा हैhttps://github.com/JSONPath-Plus/JSONPath
https://scrapfly.io/blog/parse-json-jsonpath-python/
अगर आप jq कभी-कभार ही इस्तेमाल करते हैं और हर बार docs देखने पड़ते हैं, तो gron आज़माने लायक है। यह grep किए जा सकने वाला JSON है
https://github.com/tomnomnom/gron
मैं कई सालों से
curl cheat.sh/jqइस्तेमाल करता आया हूँ, और मुझे लगता है कि cheat.sh कुल मिलाकर शानदार resource है। आजकल शायद मैं ChatGPT जैसी कोई चीज़ इस्तेमाल करूँगाgron | grep | sed | gron -uजैसा flow भी संभव हैjq को पसंद करने या सहन कर पाने की एक वजह stability है। कई साल पहले लिखी scripts आज भी ठीक वैसी ही चलती हैं
इसके उलट, yq के लिए रखा code अक्सर टूटता रहा, क्योंकि yq backward-compatible न रहने वाले तरीक़े से लगातार improve होता गया। मैंने यह जांचा नहीं कि ऐसे बदलाव कितनी बार हुए, लेकिन CI scripts जैसी जगहों पर, जहाँ default tool versions अलग-अलग होते हैं और update की रफ़्तार भी अलग होती है, कई बार असर पड़ा
इसलिए मैं हमेशा jq maintainers का आभारी रहा हूँ कि उन्होंने backward compatibility की अहमियत समझी। उम्मीद है कि यह announcement इस बात का संकेत नहीं है कि वह stability सिर्फ़ ठहराव का संयोगजन्य byproduct थी, और अब ठहराव ठीक करते हुए stability की बलि चढ़ेगी
https://kislyuk.github.io/yq/
https://github.com/kyle-long/yq#yq
https://github.com/up1/yq-1#yq-command-line-yamlxml-processo...
https://github.com/onixspot/yq-2#yq-command-line-yamlxmltoml...
https://github.com/simonrupf/convert2json#convert2json
jq जैसे tools के अलावा, jq के साथ इस्तेमाल होने वाले दिलचस्प tools में jo और jc हैं
https://github.com/jpmens/jo
https://github.com/kellyjonbrazil/jc
gron के बारे में यहाँ पहली बार सुना, लेकिन completeness के लिए जोड़ रहा हूँ। दूसरी ओर, लगता है JSON CLI tools का standard output format जैसा बनता जा रहा है। Ideal स्थिति यह होगी कि सभी CLI tools
--jsonजैसा flag दें, ताकि jc की ज़रूरत ही न रहेhttps://jless.io/
https://github.com/tomnomnom/gron
पिछले महीने की संबंधित post "First release of jq in 5 years": https://news.ycombinator.com/item?id=36951830
jq का बड़ा fan हूँ और हमेशा इस्तेमाल करता हूँ
आख़िरकार हो गया
community ने मिलकर नए maintainers recruit किए और project को फिर से ज़िंदा किया—यह process सचमुच शानदार है। खास तौर पर GitHub username के हिसाब से @stedolan, @itchyny, @owenthereal को विशेष धन्यवाद
jq और miller मेरे toolbox की essentials हैं, awk और vim के साथ
https://github.com/johnkerl/miller
नया built-in function
pick(stream)input object या array का projection emit करने की capability जोड़ता हैjq -n '{"a": 1, "b": {"c": 2, "d": 3}, "e": 4} | pick(.a, .b.c, .x)'यह सचमुच lifesaver जैसा feature है। contributors का धन्यवाद
$ jq -n '{"a": 1, "b": {"c": 2, "d": 3}, "e": 4} | {a, e}'{"a": 1,"e": 4}pickversion होjaq की भी सिफ़ारिश करना चाहूँगा। यह correctness, speed और simplicity पर focus किया हुआ jq clone है
यह jq का सिर्फ़ एक subset implement करता है, लेकिन अब तक मैं इसे काफ़ी संतोषजनक ढंग से इस्तेमाल कर रहा हूँ: https://github.com/01mf02/jaq