小编Rad*_*ord的帖子

JQ 选择存在内键的对象

credhub-ref仅当密钥存在于以下 JSON 中时,我才尝试选择凭证对象:

{
   "total_results": 23,
   "total_pages": 1,
   "prev_url": null,
   "next_url": null,
   "resources": [
      {
         "entity": {
            "credentials": {},
            "binding_options": {},
            "gateway_data": null,
            "gateway_name": "",
            "syslog_drain_url": null,
            "volume_mounts": [],
            "name": null,
            "last_operation": {
               "type": "create",
               "state": "succeeded",
               "description": "",
               "updated_at": "2018-10-15T19:13:57Z",
               "created_at": "2018-10-15T19:13:57Z"
            },
            "app_url": "/v2/3"
         }
      },
      {
         "entity": {
            "app_guid": "sd",
            "service_instance_guid": "sd",
            "credentials": {
               "hostname": "w",
               "port": 3306
            },
            "binding_options": {},
            "gateway_data": null,
            "gateway_name": "",
            "syslog_drain_url": null,
            "volume_mounts": [],
            "name": null,
            "last_operation": {
               "type": "create",
               "state": …
Run Code Online (Sandbox Code Playgroud)

json object filter jq

5
推荐指数
2
解决办法
6010
查看次数

JQ 选择值包含字符串且值不为空的对象

尝试从 JSON 数组中选择对象,其中值包含字符串且值不为空。

期望的输出:

    {
      "configurable": false,
      "property_reference": ".properties.blobstore_certificate",
      "property_type": "rsa_cert_credentials",
      "product_guid": "p-blah-29d4678e926cf2069871",
      "location": "ops_manager",
      "variable_path": "something",
      "issuer": "/C=US/O=Blah",
      "valid_from": "2019-01-16T19:55:11Z",
      "valid_until": "2021-01-16T19:55:11Z"
    }
Run Code Online (Sandbox Code Playgroud)

选择时:

{
  "certificates": [
    {
      "configurable": false,
      "property_reference": ".properties.director_ssl",
      "property_type": "rsa_cert_credentials",
      "product_guid": "p-blah-29d4678e926cf2069871",
      "location": "ops_manager",
      "variable_path": null,
      "issuer": "/C=US/O=Blah",
      "valid_from": "2019-01-16T19:55:10Z",
      "valid_until": "2021-01-16T19:55:10Z"
    },
    {
      "configurable": false,
      "property_reference": ".properties.uaa_ssl",
      "property_type": "rsa_cert_credentials",
      "product_guid": "p-blah-29d4678e926cf2069871",
      "location": "ops_manager",
      "variable_path": null,
      "issuer": "/C=US/O=Blah",
      "valid_from": "2019-01-16T19:55:10Z",
      "valid_until": "2021-01-16T19:55:10Z"
    },
    {
      "configurable": false,
      "property_reference": ".properties.blobstore_certificate",
      "property_type": "rsa_cert_credentials",
      "product_guid": "p-blah-29d4678e926cf2069871",
      "location": "ops_manager",
      "variable_path": …
Run Code Online (Sandbox Code Playgroud)

null select json jq

1
推荐指数
1
解决办法
1576
查看次数

标签 统计

jq ×2

json ×2

filter ×1

null ×1

object ×1

select ×1