G.kalyan
G.kalyan

Reputation: 41

Conditions In Jq tool

Greetings for the day!

how to get "created" value if "toString" value is Code Review from below json code.

Json code:-

  {
  "expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
  "id": "562940",
  "self": "https://example/rest/api/2/issue/562940",
  "key": "TPR-13098",
  "fields": {
    "customfield_17384": null,
    "customfield_17379": null,
    "customfield_17378": null,
    "labels": [
      
    ],
    "customfield_15505": null,
    "issuelinks": [
      
    ],
    "customfield_11709": null,
    "assignee": {
      "self": "https://example/rest/api/2/user?username=example",
      "name": "example",
      "key": "example",
      "emailAddress": "example@sample",
      "avatarUrls": {
        "48x48": "https://example/secure/useravatar?ownerId=example&avatarId=12908",
        "24x24": "https://example/secure/useravatar?size=small&ownerId=example&avatarId=12908",
        "16x16": "https://example/secure/useravatar?size=xsmall&ownerId=example&avatarId=12908",
        "32x32": "https://example/secure/useravatar?size=medium&ownerId=example&avatarId=12908"
      },
      "displayName": "example",
      "active": true,
      "timeZone": "Asia/Kolkata"
    },
    "components": [
      {
        "self": "https://example/rest/api/2/component/17139",
        "id": "17139",
        "name": "Others"
      }
    ],
    "customfield_17366": null,
    "customfield_11935": [
      {
        "self": "https://example/rest/api/2/user?username=testuser",
        "name": "testuser",
        "key": "testuser",
        "emailAddress": "testuser@sample",
        "avatarUrls": {
          "48x48": "https://example/secure/useravatar?avatarId=15907",
          "24x24": "https://example/secure/useravatar?size=small&avatarId=15907",
          "16x16": "https://example/secure/useravatar?size=xsmall&avatarId=15907",
          "32x32": "https://example/secure/useravatar?size=medium&avatarId=15907"
        },
        "displayName": "testuser",
        "active": true,
        "timeZone": "Asia/Kolkata"
      }
    ],
    "customfield_11937": null,
    "customfield_17351": "2021-06-30",
    "subtasks": [
      
    ],
    "customfield_17352": null,
    "customfield_17359": null,
    "reporter": {
      "self": "https://example/rest/api/2/user?username=testuser",
      "name": "testuser",
      "key": "testuser",
      "emailAddress": "testuser@sample",
      "avatarUrls": {
        "48x48": "https://example/secure/useravatar?avatarId=15907",
        "24x24": "https://example/secure/useravatar?size=small&avatarId=15907",
        "16x16": "https://example/secure/useravatar?size=xsmall&avatarId=15907",
        "32x32": "https://example/secure/useravatar?size=medium&avatarId=15907"
      },
      "displayName": "testuser",
      "active": true,
      "timeZone": "Asia/Kolkata"
    },
    "customfield_17357": null,
    "customfield_16700": null,
    "customfield_11920": null,
    "customfield_11922": null,
    "progress": {
      "progress": 0,
      "total": 0
    },
    "worklog": {
      "startAt": 0,
      "maxResults": 20,
      "total": 0,
      "worklogs": [
        
      ]
    },
    "issuetype": {
      "self": "https://example/rest/api/2/issuetype/12506",
      "id": "12506",
      "description": "",
      "iconUrl": "https://example/secure/viewavatar?size=xsmall&avatarId=10306&avatarType=issuetype",
      "name": "Work Item",
      "subtask": false,
      "avatarId": 10306
    },
    "customfield_17102": null,
    "customfield_17347": null,
    "project": {
      "self": "https://example/rest/api/2/project/14309",
      "id": "14309",
      "key": "TPR",
      "name": "TallyPrime",
      "projectTypeKey": "software",
      "avatarUrls": {
        "48x48": "https://example/secure/projectavatar?avatarId=10703",
        "24x24": "https://example/secure/projectavatar?size=small&avatarId=10703",
        "16x16": "https://example/secure/projectavatar?size=xsmall&avatarId=10703",
        "32x32": "https://example/secure/projectavatar?size=medium&avatarId=10703"
      }
    },
    "customfield_17346": null,
    "customfield_17103": null,
    "customfield_17345": "-",
    "customfield_15602": null,
    "customfield_11486": null,
    "customfield_15600": null,
    "customfield_15601": null,
    "customfield_16806": null,
    "customfield_16804": null,
    "customfield_11910": null,
    "customfield_16803": null,
    "customfield_11913": "2021-06-28",
    "customfield_11912": null,
    "customfield_11915": "2021-06-28",
    "resolutiondate": null,
    "customfield_11914": null,
    "watches": {
      "self": "https://example/rest/api/2/issue/TPR-13098/watchers",
      "watchCount": 1,
      "isWatching": false
    },
    "customfield_16002": null,
    "customfield_17333": null,
    "customfield_17331": 0.0,
    "customfield_17330": null,
    "customfield_16006": null,
    "customfield_16005": null,
    "customfield_16003": null,
    "customfield_16802": null,
    "customfield_16009": null,
    "customfield_16801": null,
    "customfield_16800": null,
    "customfield_17339": null,
    "customfield_16007": null,
    "customfield_17338": null,
    "updated": "2021-06-29T17:40:13.000+0530",
    "customfield_17322": null,
    "customfield_17321": null,
    "timeoriginalestimate": null,
    "customfield_17326": null,
    "description": "Clean up of JsonElem::GetOwnName as it is duplicate of JsonElem::GetKey.",
    "customfield_10010": "0|i2he8j:",
    "customfield_17323": null,
    "customfield_11344": 0.0,
    "customfield_17329": null,
    "timetracking": {
      
    },
    "customfield_15700": {
      "self": "https://example/rest/api/2/customFieldOption/16104",
      "value": "Thank you",
      "id": "16104"
    },
    "customfield_10005": null,
    "customfield_14726": null,
    "customfield_10006": null,
    "customfield_14724": null,
    "customfield_14725": null,
    "summary": "Clean up of GetOwnName from JsonElem class",
    "customfield_16101": null,
    "customfield_17311": null,
    "customfield_16100": null,
    "customfield_17310": null,
    "customfield_16103": null,
    "customfield_16102": null,
    "customfield_17312": null,
    "customfield_14722": null,
    "customfield_14723": null,
    "customfield_17318": null,
    "customfield_14721": null,
    "customfield_11204": null,
    "customfield_11205": "0.0",
    "environment": null,
    "customfield_11206": 0.0,
    "customfield_10118": null,
    "duedate": null,
    "comment": {
      "comments": [
        
      ],
      "maxResults": 0,
      "total": 0,
      "startAt": 0
    },
    "customfield_17300": null,
    "customfield_17304": "3.Coding",
    "customfield_17303": null,
    "fixVersions": [
      {
        "self": "https://example/rest/api/2/version/18013",
        "id": "18013",
        "description": "This is for Release B1 of GST Revamp planned as part of TallyPrime",
        "name": "TallyPrime Release 3.0",
        "archived": false,
        "released": false
      }
    ],
    "customfield_17301": {
      "self": "https://example/rest/api/2/customFieldOption/18133",
      "value": "Client",
      "id": "18133"
    },
    "customfield_15800": null,
    "customfield_17307": {
      "self": "https://example/rest/api/2/user?username=example",
      "name": "example",
      "key": "example",
      "emailAddress": "example@sample",
      "avatarUrls": {
        "48x48": "https://example/secure/useravatar?ownerId=example&avatarId=12908",
        "24x24": "https://example/secure/useravatar?size=small&ownerId=example&avatarId=12908",
        "16x16": "https://example/secure/useravatar?size=xsmall&ownerId=example&avatarId=12908",
        "32x32": "https://example/secure/useravatar?size=medium&ownerId=example&avatarId=12908"
      },
      "displayName": "example",
      "active": true,
      "timeZone": "Asia/Kolkata"
    },
    "customfield_17305": null,
    "customfield_14704": null,
    "customfield_14705": null,
    "timeestimate": null,
    "status": {
      "self": "https://example/rest/api/2/status/12606",
      "description": "",
      "iconUrl": "https://example/images/icons/statuses/generic.png",
      "name": "Code Review",
      "id": "12606",
      "statusCategory": {
        "self": "https://example/rest/api/2/statuscategory/4",
        "id": 4,
        "key": "indeterminate",
        "colorName": "yellow",
        "name": "In Progress"
      }
    },
    "customfield_17403": null,
    "customfield_17401": null,
    "customfield_15102": {
      "self": "https://example/rest/api/2/customFieldOption/18132",
      "value": "Code Improvement",
      "id": "18132"
    },
    "customfield_17400": null,
    "customfield_15900": null,
    "customfield_17406": null,
    "customfield_17405": null,
    "customfield_17404": null,
    "customfield_14802": null,
    "aggregatetimeestimate": null,
    "creator": {
      "self": "https://example/rest/api/2/user?username=testuser",
      "name": "testuser",
      "key": "testuser",
      "emailAddress": "testuser@sample",
      "avatarUrls": {
        "48x48": "https://example/secure/useravatar?avatarId=15907",
        "24x24": "https://example/secure/useravatar?size=small&avatarId=15907",
        "16x16": "https://example/secure/useravatar?size=xsmall&avatarId=15907",
        "32x32": "https://example/secure/useravatar?size=medium&avatarId=15907"
      },
      "displayName": "testuser",
      "active": true,
      "timeZone": "Asia/Kolkata"
    },
    "aggregateprogress": {
      "progress": 0,
      "total": 0
    },
    "timespent": null,
    "customfield_15202": [
      
    ],
    "customfield_15203": null,
    "customfield_15200": null,
    "customfield_15201": null,
    "aggregatetimespent": null,
    "customfield_15204": null,
    "workratio": -1,
    "customfield_15306": null,
    "customfield_15303": null,
    "attachment": [
      
    ],
    "customfield_10527": null,
    "customfield_10518": null
  },
  "changelog": {
    "startAt": 0,
    "maxResults": 4,
    "total": 4,
    "histories": [
      {
        "id": "3818773",
        "author": {
          "self": "https://example/rest/api/2/user?username=testuser",
          "name": "testuser",
          "key": "testuser",
          "emailAddress": "testuser@sample",
          "avatarUrls": {
            "48x48": "https://example/secure/useravatar?avatarId=15907",
            "24x24": "https://example/secure/useravatar?size=small&avatarId=15907",
            "16x16": "https://example/secure/useravatar?size=xsmall&avatarId=15907",
            "32x32": "https://example/secure/useravatar?size=medium&avatarId=15907"
          },
          "displayName": "testuser",
          "active": true,
          "timeZone": "Asia/Kolkata"
        },
        "created": "2021-06-28T16:34:02.000+0530",
        "items": [
          {
            "field": "status",
            "fieldtype": "jira",
            "from": "10114",
            "fromString": "New",
            "to": "12605",
            "toString": "Coding"
          }
        ]
      },
      {
        "id": "3818870",
        "author": {
          "self": "https://example/rest/api/2/user?username=testuser",
          "name": "testuser",
          "key": "testuser",
          "emailAddress": "testuser@sample",
          "avatarUrls": {
            "48x48": "https://example/secure/useravatar?avatarId=15907",
            "24x24": "https://example/secure/useravatar?size=small&avatarId=15907",
            "16x16": "https://example/secure/useravatar?size=xsmall&avatarId=15907",
            "32x32": "https://example/secure/useravatar?size=medium&avatarId=15907"
          },
          "displayName": "testuser",
          "active": true,
          "timeZone": "Asia/Kolkata"
        },
        "created": "2021-06-28T17:23:44.000+0530",
        "items": [
          {
            "field": "status",
            "fieldtype": "jira",
            "from": "12605",
            "fromString": "Coding",
            "to": "12606",
            "toString": "Code Review"
          }
        ]
      },
      {
        "id": "3820419",
        "author": {
          "self": "https://example/rest/api/2/user?username=example",
          "name": "example",
          "key": "example",
          "emailAddress": "example@sample",
          "avatarUrls": {
            "48x48": "https://example/secure/useravatar?ownerId=example&avatarId=12908",
            "24x24": "https://example/secure/useravatar?size=small&ownerId=example&avatarId=12908",
            "16x16": "https://example/secure/useravatar?size=xsmall&ownerId=example&avatarId=12908",
            "32x32": "https://example/secure/useravatar?size=medium&ownerId=example&avatarId=12908"
          },
          "displayName": "example",
          "active": true,
          "timeZone": "Asia/Kolkata"
        },
        "created": "2021-06-29T17:40:12.000+0530",
        "items": [
          {
            "field": "Coding Due Date",
            "fieldtype": "custom",
            "from": null,
            "fromString": null,
            "to": "2021-06-30",
            "toString": "30/Jun/21"
          }
        ]
      },
      {
        "id": "3820420",
        "author": {
          "self": "https://example/rest/api/2/user?username=example",
          "name": "example",
          "key": "example",
          "emailAddress": "example@sample",
          "avatarUrls": {
            "48x48": "https://example/secure/useravatar?ownerId=example&avatarId=12908",
            "24x24": "https://example/secure/useravatar?size=small&ownerId=example&avatarId=12908",
            "16x16": "https://example/secure/useravatar?size=xsmall&ownerId=example&avatarId=12908",
            "32x32": "https://example/secure/useravatar?size=medium&ownerId=example&avatarId=12908"
          },
          "displayName": "example",
          "active": true,
          "timeZone": "Asia/Kolkata"
        },
        "created": "2021-06-29T17:40:13.000+0530",
        "items": [
          {
            "field": "assignee",
            "fieldtype": "jira",
            "from": "testuser",
            "fromString": "testuser",
            "to": "example",
            "toString": "example"
          }
        ]
      }
    ]
  }
}

Upvotes: 0

Views: 85

Answers (1)

peak
peak

Reputation: 117017

..
| objects
| select(has("created") and any(.items[]; .toString == "Code Review"))
| .created

Research Effort

For future reference, please note that, since you've been a member of the SO community for over a year and have asked other questions, you should be familiar with the SO guidelines for asking appropriate questions. Apart from the "miminum reproducible example" guidelines already mentioned on this page, there should be some evidence of "research effort" as per How much research effort is expected of Stack Overflow users?

Upvotes: 1

Related Questions