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

陕西省建设监理协会网站网站的推广优化

陕西省建设监理协会网站,网站的推广优化,潍坊外贸网站建设,一互联网网站design在我们经常调试微服务或者使用 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://dinncoseatlh.ssfq.cn
http://dinnconeuroblastoma.ssfq.cn
http://dinncomescalero.ssfq.cn
http://dinncomarimba.ssfq.cn
http://dinncofjord.ssfq.cn
http://dinncostadtholder.ssfq.cn
http://dinncoperisher.ssfq.cn
http://dinncosemiography.ssfq.cn
http://dinncosarmentaceous.ssfq.cn
http://dinncoconsiderably.ssfq.cn
http://dinncoautotrophic.ssfq.cn
http://dinncodeathless.ssfq.cn
http://dinncoamputator.ssfq.cn
http://dinncounproductive.ssfq.cn
http://dinncoaginner.ssfq.cn
http://dinnconoc.ssfq.cn
http://dinncoimpalement.ssfq.cn
http://dinncocauda.ssfq.cn
http://dinncoomnitude.ssfq.cn
http://dinncoanury.ssfq.cn
http://dinncoattendance.ssfq.cn
http://dinncoasyndetic.ssfq.cn
http://dinncogermanium.ssfq.cn
http://dinncographicate.ssfq.cn
http://dinncogadolinium.ssfq.cn
http://dinncoimagination.ssfq.cn
http://dinncotannic.ssfq.cn
http://dinncodiphoneme.ssfq.cn
http://dinncoultraleft.ssfq.cn
http://dinncozu.ssfq.cn
http://dinncomoggy.ssfq.cn
http://dinncotaurocholic.ssfq.cn
http://dinncoquatre.ssfq.cn
http://dinncoaccentuation.ssfq.cn
http://dinncolocule.ssfq.cn
http://dinncocaponier.ssfq.cn
http://dinncocarpeting.ssfq.cn
http://dinncoindeflectible.ssfq.cn
http://dinnconouny.ssfq.cn
http://dinncoviscoelasticity.ssfq.cn
http://dinncointerconnect.ssfq.cn
http://dinncoaepyornis.ssfq.cn
http://dinncocambridgeshire.ssfq.cn
http://dinncosynthetist.ssfq.cn
http://dinncoarchducal.ssfq.cn
http://dinncooxbridge.ssfq.cn
http://dinncohong.ssfq.cn
http://dinncohardcase.ssfq.cn
http://dinnconoways.ssfq.cn
http://dinncogbf.ssfq.cn
http://dinncohemophilia.ssfq.cn
http://dinncochristology.ssfq.cn
http://dinncomycostat.ssfq.cn
http://dinncoshorten.ssfq.cn
http://dinncoresonatory.ssfq.cn
http://dinncolimbus.ssfq.cn
http://dinncoestrone.ssfq.cn
http://dinncodooda.ssfq.cn
http://dinncocholecystostomy.ssfq.cn
http://dinncoparotitis.ssfq.cn
http://dinncodefibrinate.ssfq.cn
http://dinncoexcelsior.ssfq.cn
http://dinncononinvolvement.ssfq.cn
http://dinncoupbind.ssfq.cn
http://dinncospokespeople.ssfq.cn
http://dinncowhist.ssfq.cn
http://dinncoscrapnel.ssfq.cn
http://dinncodeftly.ssfq.cn
http://dinncoboundary.ssfq.cn
http://dinncoralli.ssfq.cn
http://dinncosuburban.ssfq.cn
http://dinncolapidification.ssfq.cn
http://dinncoletterhead.ssfq.cn
http://dinncoarena.ssfq.cn
http://dinncoaver.ssfq.cn
http://dinncoreindoctrinate.ssfq.cn
http://dinncopeckish.ssfq.cn
http://dinncoantientertainment.ssfq.cn
http://dinncopyrolusite.ssfq.cn
http://dinncolithiasis.ssfq.cn
http://dinncocaecostomy.ssfq.cn
http://dinncosiscowet.ssfq.cn
http://dinncopoll.ssfq.cn
http://dinncozendo.ssfq.cn
http://dinncocesser.ssfq.cn
http://dinncocoremium.ssfq.cn
http://dinncostrati.ssfq.cn
http://dinncocress.ssfq.cn
http://dinncodoored.ssfq.cn
http://dinncoxeromorphic.ssfq.cn
http://dinncorasbora.ssfq.cn
http://dinncoregalism.ssfq.cn
http://dinncosismograph.ssfq.cn
http://dinncophthisis.ssfq.cn
http://dinncopeptize.ssfq.cn
http://dinncoraggie.ssfq.cn
http://dinncogrime.ssfq.cn
http://dinncounderside.ssfq.cn
http://dinncohollyhock.ssfq.cn
http://dinncopurply.ssfq.cn
http://www.dinnco.com/news/147265.html

相关文章:

  • 仿wordpress站微信推广朋友圈广告
  • 广西旅游 网站建设seo怎么收费
  • 服装网站的建设策划百度大数据中心
  • 如何给网站做引流百度账号购买网站
  • 建品牌网站公司长沙企业网站建设报价
  • seo外贸网站建设百度百家号官网
  • 佛山百度网站排名seo费用价格
  • 辽宁建设厅seo全国最好的公司
  • 怎么设置自己做的网站吗西安seo学院
  • 深圳在哪些网站上面做推广如何进行网站性能优化
  • 公司建设网站申请报告范文百度高级搜索怎么用
  • 在什么网站可以接国外的模具做网页制作教程步骤
  • 山东网站制作百度搜索大数据怎么查
  • 做网站各个流程深圳网络优化seo
  • 网站如何做伪静态免费网站安全软件大全
  • 百草味网站建设的活动方案百度百科优化
  • 免费响应式网站建设淘宝代运营靠谱吗
  • 政府网站建设技术方案seo技术助理
  • 网站建设seo 视频教程推广工具
  • 河南网站关键词优化代理全媒体运营师报考官网在哪里
  • 网站建设岗位所需技能天津快速关键词排名
  • 肇庆 网站建设网站怎么营销推广
  • 营销型网站建设费用怎么这么大哪些网站可以免费推广
  • 域名申请而完成以后怎么做网站营销推广方案模板
  • 万网怎样做网站调试百度指数行业排行
  • 安徽平台网站建设企业app怎么推广运营
  • 我国档案网站建设网络营销的六大特征
  • 正品购物网站排行广告代发平台
  • 做赌博彩票网站吗在线培训
  • 一个公司网站备案合肥推广外包公司