jq

jq 1.5 multiple bash variables as argument

99封情书 提交于 2020-12-15 01:45:52
问题 I'm working on a script for my openwrt, a watchdog for my pia connection. I'm trying to make this little jq filter but every time I try I get error I've more options and I "compose" the jq filter all_region_data=$(curl -s "https://serverlist.piaservers.net/vpninfo/servers/v4" | head -1) BestRegion="italy" jq_filter='.regions[]' if [ -z "$BestRegion" ]; then # BestRegion not forced if [ "$pia_pf" = "true" ]; then jq_filter="${jq_filter} | select(.port_forward==true)" fi if [ "$pia_no_geo" =

jq 1.5 multiple bash variables as argument

寵の児 提交于 2020-12-15 01:45:41
问题 I'm working on a script for my openwrt, a watchdog for my pia connection. I'm trying to make this little jq filter but every time I try I get error I've more options and I "compose" the jq filter all_region_data=$(curl -s "https://serverlist.piaservers.net/vpninfo/servers/v4" | head -1) BestRegion="italy" jq_filter='.regions[]' if [ -z "$BestRegion" ]; then # BestRegion not forced if [ "$pia_pf" = "true" ]; then jq_filter="${jq_filter} | select(.port_forward==true)" fi if [ "$pia_no_geo" =

jq 1.5 multiple bash variables as argument

佐手、 提交于 2020-12-15 01:45:30
问题 I'm working on a script for my openwrt, a watchdog for my pia connection. I'm trying to make this little jq filter but every time I try I get error I've more options and I "compose" the jq filter all_region_data=$(curl -s "https://serverlist.piaservers.net/vpninfo/servers/v4" | head -1) BestRegion="italy" jq_filter='.regions[]' if [ -z "$BestRegion" ]; then # BestRegion not forced if [ "$pia_pf" = "true" ]; then jq_filter="${jq_filter} | select(.port_forward==true)" fi if [ "$pia_no_geo" =

Whitelisting objects using select

喜欢而已 提交于 2020-12-13 04:14:06
问题 I'm trying to filter lists using contains function, provided by jq. My input , [1, 2, 3, 4, 5] And I have a "whitelist" : [3, 4, 7] I need to filter input list through whitelist. Expected output : [3, 4] I'm able to filter comparing a single item: jq --compact-output --null-input '[1,2,3,4,5] | map(select(. | contains(3)))' [3] I tried this: $ jq --compact-output --null-input '[1,2,3,4,5] | map(select([3,4,7] | contains([.])))' [] $ Here [3,4,7] | contains([.]) intents to pose question: is [.

vue 路由懒加载

霸气de小男生 提交于 2020-12-12 18:32:04
题外: 我司目前的后台管理网站依旧是 jq + xxUI 构成的 ,早就想把 丫儿 个换成 vue了, 苦于整个组几乎一致处于一个忙碌的状态,没有时间来重构。 然鹅,昨天今天组长找到我说要用 vue 搞起来,这个问题不大,毕竟之前用他完成了几个项目,颇有收获,教训满满。 看着 左侧 冗长菜单 item ,不禁陷入了沉思。 当打包构建应用时,Javascript 包会变得非常大,首次加载即便使用了 各种 LOADING ,各种 动画,肯定体验贼差, 如果我们能把不同路由对应的组件分割成不同的代码块,然后当路由被访问的时候才加载对应组件,这样就更加高效了。 路由懒加载 于是想到了 vue 路由懒加载 这个路子, vue-router 支持WebPack内置的异步模块加载系统,只需要在路由被访问时按需加载。 嗯,搞个 demo 出来先。 1 初始化一个项目,建立三个页面,分别绑定路由 import Vue from 'vue' import Router from 'vue-router' import home from '@/components/home' import icon from '@/components/icon' import progress from '@/components/progress' Vue.use(Router) export default

怎样提高js的编程能力

与世无争的帅哥 提交于 2020-12-11 08:00:48
1,学习js分几个阶段,没入门,入门初学者,中级水平,高级水平,ppt水平。 2,没入门的如何学习? 我当初是先学jquery,有css和html基础,有css基础看jq的语法很简单,就是选择符,jq的api懂高中英语就够了,猜也猜的出来意思,然后下载基本jq的chm手册,对着挨个看一遍。(这个挨个看一遍的意思就是一行一句的逐个看一遍,看不懂的别死扣,先看完再说)。 看完一遍之后,心中有数,哦,原来有个ajax函数可以访问网络资源,有个success可以写回调方法,超时怎么办?几个一起同时发怎么办?不管了,用到再说。哦,原来有个find函数可以查找dom节点,哦,原来有个serialize函数可以序列化表单值,哦,原来有个toggle函数可以做切换用,哦,有个fn可以挂着写插件用,哦,切换cls这样做就行了,哦,请求json数据这样配置参数就可以了。 做到了解,你就成功了,用到的时候知道jq能干什么,不能干什么,干什么的时候去看哪一章,再去仔细研究,做东西开始有点慢,做起来几个东西之后就手熟了。 同理,我学习yui2,kissy,mootools,nodejs,react,ng,甚至swift部分也是这样对着手册来的,反复几遍就可以了。 入门的意思就是概括一下,我知道有哪些api能干什么,具体怎么干,用的时候再说。 2,入门初学者。 我看完手册了,也写了几个小项目了

Iterate through dictionaries jq - shell

久未见 提交于 2020-12-06 06:35:46
问题 I have a JSON like this { "images" : [ { "size" : "29x29", "idiom" : "iphone", "filename" : "Icon-Small@2x.png", "scale" : "2x" } ...... ...... { "size" : "60x60", "idiom" : "iphone", "filename" : "Icon-60@3x.png", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } I want to iterate through each dictionary in images array. For that I wrote declare -a images=($(cat Contents.json | jq ".images[]")) for image in "${images[@]}" do echo "image --$image" done I am expecting output

Iterate through dictionaries jq - shell

為{幸葍}努か 提交于 2020-12-06 06:32:49
问题 I have a JSON like this { "images" : [ { "size" : "29x29", "idiom" : "iphone", "filename" : "Icon-Small@2x.png", "scale" : "2x" } ...... ...... { "size" : "60x60", "idiom" : "iphone", "filename" : "Icon-60@3x.png", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } I want to iterate through each dictionary in images array. For that I wrote declare -a images=($(cat Contents.json | jq ".images[]")) for image in "${images[@]}" do echo "image --$image" done I am expecting output

Iterate through dictionaries jq - shell

安稳与你 提交于 2020-12-06 06:32:24
问题 I have a JSON like this { "images" : [ { "size" : "29x29", "idiom" : "iphone", "filename" : "Icon-Small@2x.png", "scale" : "2x" } ...... ...... { "size" : "60x60", "idiom" : "iphone", "filename" : "Icon-60@3x.png", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } I want to iterate through each dictionary in images array. For that I wrote declare -a images=($(cat Contents.json | jq ".images[]")) for image in "${images[@]}" do echo "image --$image" done I am expecting output

Iterate through dictionaries jq - shell

扶醉桌前 提交于 2020-12-06 06:32:12
问题 I have a JSON like this { "images" : [ { "size" : "29x29", "idiom" : "iphone", "filename" : "Icon-Small@2x.png", "scale" : "2x" } ...... ...... { "size" : "60x60", "idiom" : "iphone", "filename" : "Icon-60@3x.png", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } I want to iterate through each dictionary in images array. For that I wrote declare -a images=($(cat Contents.json | jq ".images[]")) for image in "${images[@]}" do echo "image --$image" done I am expecting output