当前位置: 首页 > news >正文

网站模板html 汽车膜产品宣传推广方案

网站模板html 汽车膜,产品宣传推广方案,个人衣服定制店铺,平台推广渠道在我们经常调试微服务或者使用 Elasticsearch API 时,经常会使用curl 来进行调试。但是有时我们的输出不尽如意。显示的不是一 pretty 格式进行输出的。我们有时还必须借助于其他的一些网站工具,比如 Best JSON Formatter and JSON Validator: Online JS…

在我们经常调试微服务或者使用 Elasticsearch API 时,经常会使用curl 来进行调试。但是有时我们的输出不尽如意。显示的不是一 pretty 格式进行输出的。我们有时还必须借助于其他的一些网站工具,比如 Best JSON Formatter and JSON Validator: Online JSON Formatter  或者 JSON Formatter & Validator 来帮我来验证。

在 Elasticsearch 的输出中经常我们会看到如下格式的命令:

curl -k -u elastic:gV4pgxNCTi5y*80GmoqN https://localhost:9200?pretty=true

这里的 pretty 就是要求我们要以 JSON 的格式来进行显示。尽管我们上面的命令可以省去 pretty=true 这个选项,可以还是可以得到漂亮的输出:

curl -k -u elastic:gV4pgxNCTi5y*80GmoqN https://localhost:9200
{"name" : "liuxgm.local","cluster_name" : "elasticsearch","cluster_uuid" : "xz4jLE_USfmbvkSyvG138w","version" : {"number" : "8.6.1","build_flavor" : "default","build_type" : "tar","build_hash" : "180c9830da956993e59e2cd70eb32b5e383ea42c","build_date" : "2023-01-24T21:35:11.506992272Z","build_snapshot" : false,"lucene_version" : "9.4.2","minimum_wire_compatibility_version" : "7.17.0","minimum_index_compatibility_version" : "7.0.0"},"tagline" : "You Know, for Search"
}

我们可以看如下的命令的输出:

curl -k  https://localhost:9200?pretty=true
curl -k  https://localhost:9200?pretty=true
{"error" : {"root_cause" : [{"type" : "security_exception","reason" : "missing authentication credentials for REST request [/?pretty=true]","header" : {"WWW-Authenticate" : ["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}}],"type" : "security_exception","reason" : "missing authentication credentials for REST request [/?pretty=true]","header" : {"WWW-Authenticate" : ["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}},"status" : 401
}

我们可以看到很漂亮的输出。一旦我们省去 pretty=true 这个选项,那么我们看看输出的结果是什么:

$ curl -k  https://localhost:9200
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}},"status":401}$

很显然,我们的显示非常不漂亮,很难看懂它的意思。

在 Elasticsearch 中,我们的很多命令都可以使用 pretty=true 选项来变得更加美观。

但是在实际的用例中,有很多并不像 Elasticsearch 那样。它们的命令中并没有像 Elasticsearch 那样提供 pretty=true 这样的选项。那么我们该怎么办呢?

在下面,我来介绍几种方案:

使用 json_pp

我们尝试使用如下的命令:

echo '{"type":"Bar","id":"1","title":"Foo"}' | json_pp -json_opt pretty,canonical
$ echo '{"type":"Bar","id":"1","title":"Foo"}' | json_pp -json_opt pretty,canonical
{"id" : "1","title" : "Foo","type" : "Bar"
}

很显然,它能帮我们把 JSON 的输出变得很漂亮。我们来尝试一下上面的 Elasticsearch 访问:

$ curl -k  https://localhost:9200 | json_pp -json_opt pretty,canonical% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100   459  100   459    0     0  29436      0 --:--:-- --:--:-- --:--:-- 38250
{"error" : {"header" : {"WWW-Authenticate" : ["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]},"reason" : "missing authentication credentials for REST request [/]","root_cause" : [{"header" : {"WWW-Authenticate" : ["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]},"reason" : "missing authentication credentials for REST request [/]","type" : "security_exception"}],"type" : "security_exception"},"status" : 401
}

很显然,它也工作正常。

使用 jq

我们需要单独安装 jq。我们使用如下的命令来进行验证:

echo '{"type":"Bar","id":"1","title":"Foo"}' | jq '.'
$ echo '{"type":"Bar","id":"1","title":"Foo"}' | jq '.'
{"type": "Bar","id": "1","title": "Foo"
}

显然这种方法比上面的方法更为简洁。我们也可以使用它来试一下 Elasticsearch 的访问:

curl -k  https://localhost:9200 | jq '.'

它还有彩色的输出。显得非常漂亮。

 

使用 python

我们使用如下的例子来进行展示:

echo '{"type":"Bar","id":"1","title":"Foo"}' | python -m json.tool
$ echo '{"type":"Bar","id":"1","title":"Foo"}' | python -m json.tool
{"type": "Bar","id": "1","title": "Foo"
}

尝试一下 Elasticsearch API:

它和 jq 输出的结果很相似,除了没有彩色的显示。

我们还可以使用 curljson 命令:

pip install curljson
 curljson -k https://localhost:9200
{"error": {"header": {"WWW-Authenticate": ["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]},"reason": "missing authentication credentials for REST request [/]","root_cause": [{"header": {"WWW-Authenticate": ["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]},"reason": "missing authentication credentials for REST request [/]","type": "security_exception"}],"type": "security_exception"},"status": 401
}

使用 Nodejs

echo '{"type":"Bar","id":"1","title":"Foo"}' | node -e "console.log( JSON.stringify( JSON.parse(require('fs').readFileSync(0) ), 0, 1 ))"
$ echo '{"type":"Bar","id":"1","title":"Foo"}' | node -e "console.log( JSON.stringify( JSON.parse(require('fs').readFileSync(0) ), 0, 1 ))"
{"type": "Bar","id": "1","title": "Foo"
}

很显然这种方法非常笨拙。你也可以采用如下的方法:

echo '{"foo": "lorem", "bar": "ipsum"}' | npx json
echo '{"foo": "lorem", "bar": "ipsum"}' | npx json
{"foo": "lorem","bar": "ipsum"
}

使用 json_reformat

在 Linux 机器上安装 yajl-tools 安装包,然后使用如下的命令:

echo '{"foo": "lorem", "bar": "ipsum"}' | json_reformat
{"foo": "lorem","bar": "ipsum"
}
http://www.tdrn.cn/news/191.html

相关文章:

  • 网站建设2017排名长沙网站推广
  • php网站开发报告书网络营销是什么专业
  • wordpress 定时任务沈阳seo排名优化教程
  • 万网企业邮箱百度seo公司哪家最好
  • 做技能培训和那个网站合作好谷歌google play官网下载
  • wordpress菜单跳转页面跳转seo教程技术优化搜索引擎
  • 杭州建设网站网站郑州seo优化顾问热狗
  • ssh框架做的网站问题怎么制作链接网页
  • 什么是部署php网站怎么制作网页里面的内容
  • 2017一起做网店网站seo兼职
  • 深圳购物网站建设免费制作网页平台
  • 怎么自己做礼品网站怎么做产品推广和宣传
  • 禹州网站建设如何在各大网站发布信息
  • 武汉做营销型网站建设西安做网站公司
  • 芜湖酒店网站建设百度有免费推广广告
  • 湖州高端网站设计百度新闻网页
  • 苏州城乡建设网站查询系统产品怎么在网上推广
  • 陕西企业电脑网站制作免费制作网站的软件
  • 深圳产品型网站建设西安做网站
  • 郑州网站开发与建设宁德seo优化
  • 做阿胶上什么网站比较好自媒体推广
  • 小米路由2 做网站合川网站建设
  • asp网站制作免费模板下载seo免费课程视频
  • 广州市网站建设服务机构不错宁波seo公司
  • w做网站诈骗百度客服电话是多少
  • vs2010怎么做网站前台南宁 百度网盘
  • 做设计素材网站免费营销软件网站
  • 简述制作网站的流程长沙seo公司
  • 怎么做公司网站的二维码游戏代理0加盟费
  • thinkphp 微网站开发网上推广方式