jq parse json in bash2019 Community Moderator ElectionHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How to parse JSON in JavaWhy does Google prepend while(1); to their JSON responses?Parsing values from a JSON file?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?

Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?

Definition of Statistic

How many characters using PHB rules does it take to be able to have access to any PHB spell at the start of an adventuring day?

Counting all the hearts

Is "history" a male-biased word ("his+story")?

Latex does not go to next line

Makefile strange variable substitution

What problems would a superhuman have whose skin is constantly hot?

Bash script should only kill those instances of another script's that it has launched

PTIJ: Should I kill my computer after installing software?

Do items de-spawn in Diablo?

PTIJ: wiping amalek’s memory?

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

'The literal of type int is out of range' con número enteros pequeños (2 dígitos)

Reversed Sudoku

Conservation of Mass and Energy

Can Mathematica be used to create an Artistic 3D extrusion from a 2D image and wrap a line pattern around it?

Accepted offer letter, position changed

Good for you! in Russian

Plausibility of Mushroom Buildings

weren't playing vs didn't play

Could you please stop shuffling the deck and play already?

What wound would be of little consequence to a biped but terrible for a quadruped?

In the quantum hamiltonian, why does kinetic energy turn into an operator while potential doesn't?



jq parse json in bash



2019 Community Moderator ElectionHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How to parse JSON in JavaWhy does Google prepend while(1); to their JSON responses?Parsing values from a JSON file?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?










-1















I have json file and want to parse it with jq, to have in output something like this:




.issues.keys .project.self .fixVersions.id .fixVersions.name

.fixVersions.description .resolution.description .resolution.name
.versions.name .summary.summary




And here is json part:



[

"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 56,
"issues": [

"key": "AXL-2766",
"fields":
"issuetype":
"self": "https://jira/rest/api/2/issuetype/1",
"description": "desc.",
,
"project":
"self": "https://jira/rest/api/2/project/15770",
"avatarUrls":
"48x48": "https://jira/secure/projectavatar?avatarId=15683",

,
"fixVersions": [

"self": "https://jira/rest/api/2/version/18167",
"description": "description1",
"name": "0.2.0",

],
"resolution":
"self": "https://jira/rest/api/2/resolution/1",
"description": "description2",
"name": "Fixed"
,
"watches":
"self": "https://jira/rest/api/2/issue/AXL-2766/watchers",
,
"created": "2019-03-04T01:10:07.000-0500",
"priority":
"self": "https://jira/rest/api/2/priority/2",
,
"customfield_10420": null,
"customfield_12322":
"self": "https://jira/rest/api/2/customFieldOption/10644",
,
"versions": [

"self": "https://jira/rest/api/2/version/18165",
"id": "18165",
"description": "",
"name": "0.0"

],
"issuelinks": [],
"assignee":
"emailAddress": "aaa@domain.test"
,
"displayName": "user",
,
"updated": "2019-03-04T05:47:13.000-0500",
"status":
"self": "https://jira/rest/api/2/status/5",
"description": "description3.",
"statusCategory":
"colorName": "green",
"name": "Done"

,
"summary": "summary",
"creator":
"self": "https://jira/rest/api/2/user?username=user",
"emailAddress": "user.@domain.net"
,
"subtasks": [],
"reporter":
"self": "https://jira/rest/api/2/user?username=user",
"emailAddress": "user.@domain.net",
,
"aggregateprogress":
"progress": 1800,
,
"customfield_10122": null,
"progress":
"progress": 1800,
,
"votes":
"self": "https://jira/rest/api/2/issue/AXL-2766/votes",



]


I've tried but stucked in this:




.[] | issues: .issues, fields: [ .fields .fixVersions .name]




P.S json file can be damaged as I've deleted from there some private info :)










share|improve this question



















  • 1





    You'll need commas between fields (.fields, .fixVersions, .name). Also, what issue are you having?

    – aaaaaa123456789
    Mar 7 at 6:51







  • 1





    Your JSON isn't syntactically valid. Fix it first

    – Inian
    Mar 7 at 6:53











  • @aaaaaa123456789 actually there is no issues, I just need to extract that values from curl output and put them into email message. I don't know how to het multiple values from one , and cannot get name value from fixVersions

    – user37033
    Mar 7 at 7:19












  • First, please fix the JSON. Second, ensure that the example query corresponds to the example JSON, e.g. by specifying each path correctly. Third, reformulate the question so that it is clear what you want done with the fields that are array-valued. Finally, please show the output that you expect your sample query and sample JSON should produce.

    – peak
    Mar 7 at 14:41















-1















I have json file and want to parse it with jq, to have in output something like this:




.issues.keys .project.self .fixVersions.id .fixVersions.name

.fixVersions.description .resolution.description .resolution.name
.versions.name .summary.summary




And here is json part:



[

"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 56,
"issues": [

"key": "AXL-2766",
"fields":
"issuetype":
"self": "https://jira/rest/api/2/issuetype/1",
"description": "desc.",
,
"project":
"self": "https://jira/rest/api/2/project/15770",
"avatarUrls":
"48x48": "https://jira/secure/projectavatar?avatarId=15683",

,
"fixVersions": [

"self": "https://jira/rest/api/2/version/18167",
"description": "description1",
"name": "0.2.0",

],
"resolution":
"self": "https://jira/rest/api/2/resolution/1",
"description": "description2",
"name": "Fixed"
,
"watches":
"self": "https://jira/rest/api/2/issue/AXL-2766/watchers",
,
"created": "2019-03-04T01:10:07.000-0500",
"priority":
"self": "https://jira/rest/api/2/priority/2",
,
"customfield_10420": null,
"customfield_12322":
"self": "https://jira/rest/api/2/customFieldOption/10644",
,
"versions": [

"self": "https://jira/rest/api/2/version/18165",
"id": "18165",
"description": "",
"name": "0.0"

],
"issuelinks": [],
"assignee":
"emailAddress": "aaa@domain.test"
,
"displayName": "user",
,
"updated": "2019-03-04T05:47:13.000-0500",
"status":
"self": "https://jira/rest/api/2/status/5",
"description": "description3.",
"statusCategory":
"colorName": "green",
"name": "Done"

,
"summary": "summary",
"creator":
"self": "https://jira/rest/api/2/user?username=user",
"emailAddress": "user.@domain.net"
,
"subtasks": [],
"reporter":
"self": "https://jira/rest/api/2/user?username=user",
"emailAddress": "user.@domain.net",
,
"aggregateprogress":
"progress": 1800,
,
"customfield_10122": null,
"progress":
"progress": 1800,
,
"votes":
"self": "https://jira/rest/api/2/issue/AXL-2766/votes",



]


I've tried but stucked in this:




.[] | issues: .issues, fields: [ .fields .fixVersions .name]




P.S json file can be damaged as I've deleted from there some private info :)










share|improve this question



















  • 1





    You'll need commas between fields (.fields, .fixVersions, .name). Also, what issue are you having?

    – aaaaaa123456789
    Mar 7 at 6:51







  • 1





    Your JSON isn't syntactically valid. Fix it first

    – Inian
    Mar 7 at 6:53











  • @aaaaaa123456789 actually there is no issues, I just need to extract that values from curl output and put them into email message. I don't know how to het multiple values from one , and cannot get name value from fixVersions

    – user37033
    Mar 7 at 7:19












  • First, please fix the JSON. Second, ensure that the example query corresponds to the example JSON, e.g. by specifying each path correctly. Third, reformulate the question so that it is clear what you want done with the fields that are array-valued. Finally, please show the output that you expect your sample query and sample JSON should produce.

    – peak
    Mar 7 at 14:41













-1












-1








-1








I have json file and want to parse it with jq, to have in output something like this:




.issues.keys .project.self .fixVersions.id .fixVersions.name

.fixVersions.description .resolution.description .resolution.name
.versions.name .summary.summary




And here is json part:



[

"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 56,
"issues": [

"key": "AXL-2766",
"fields":
"issuetype":
"self": "https://jira/rest/api/2/issuetype/1",
"description": "desc.",
,
"project":
"self": "https://jira/rest/api/2/project/15770",
"avatarUrls":
"48x48": "https://jira/secure/projectavatar?avatarId=15683",

,
"fixVersions": [

"self": "https://jira/rest/api/2/version/18167",
"description": "description1",
"name": "0.2.0",

],
"resolution":
"self": "https://jira/rest/api/2/resolution/1",
"description": "description2",
"name": "Fixed"
,
"watches":
"self": "https://jira/rest/api/2/issue/AXL-2766/watchers",
,
"created": "2019-03-04T01:10:07.000-0500",
"priority":
"self": "https://jira/rest/api/2/priority/2",
,
"customfield_10420": null,
"customfield_12322":
"self": "https://jira/rest/api/2/customFieldOption/10644",
,
"versions": [

"self": "https://jira/rest/api/2/version/18165",
"id": "18165",
"description": "",
"name": "0.0"

],
"issuelinks": [],
"assignee":
"emailAddress": "aaa@domain.test"
,
"displayName": "user",
,
"updated": "2019-03-04T05:47:13.000-0500",
"status":
"self": "https://jira/rest/api/2/status/5",
"description": "description3.",
"statusCategory":
"colorName": "green",
"name": "Done"

,
"summary": "summary",
"creator":
"self": "https://jira/rest/api/2/user?username=user",
"emailAddress": "user.@domain.net"
,
"subtasks": [],
"reporter":
"self": "https://jira/rest/api/2/user?username=user",
"emailAddress": "user.@domain.net",
,
"aggregateprogress":
"progress": 1800,
,
"customfield_10122": null,
"progress":
"progress": 1800,
,
"votes":
"self": "https://jira/rest/api/2/issue/AXL-2766/votes",



]


I've tried but stucked in this:




.[] | issues: .issues, fields: [ .fields .fixVersions .name]




P.S json file can be damaged as I've deleted from there some private info :)










share|improve this question
















I have json file and want to parse it with jq, to have in output something like this:




.issues.keys .project.self .fixVersions.id .fixVersions.name

.fixVersions.description .resolution.description .resolution.name
.versions.name .summary.summary




And here is json part:



[

"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 56,
"issues": [

"key": "AXL-2766",
"fields":
"issuetype":
"self": "https://jira/rest/api/2/issuetype/1",
"description": "desc.",
,
"project":
"self": "https://jira/rest/api/2/project/15770",
"avatarUrls":
"48x48": "https://jira/secure/projectavatar?avatarId=15683",

,
"fixVersions": [

"self": "https://jira/rest/api/2/version/18167",
"description": "description1",
"name": "0.2.0",

],
"resolution":
"self": "https://jira/rest/api/2/resolution/1",
"description": "description2",
"name": "Fixed"
,
"watches":
"self": "https://jira/rest/api/2/issue/AXL-2766/watchers",
,
"created": "2019-03-04T01:10:07.000-0500",
"priority":
"self": "https://jira/rest/api/2/priority/2",
,
"customfield_10420": null,
"customfield_12322":
"self": "https://jira/rest/api/2/customFieldOption/10644",
,
"versions": [

"self": "https://jira/rest/api/2/version/18165",
"id": "18165",
"description": "",
"name": "0.0"

],
"issuelinks": [],
"assignee":
"emailAddress": "aaa@domain.test"
,
"displayName": "user",
,
"updated": "2019-03-04T05:47:13.000-0500",
"status":
"self": "https://jira/rest/api/2/status/5",
"description": "description3.",
"statusCategory":
"colorName": "green",
"name": "Done"

,
"summary": "summary",
"creator":
"self": "https://jira/rest/api/2/user?username=user",
"emailAddress": "user.@domain.net"
,
"subtasks": [],
"reporter":
"self": "https://jira/rest/api/2/user?username=user",
"emailAddress": "user.@domain.net",
,
"aggregateprogress":
"progress": 1800,
,
"customfield_10122": null,
"progress":
"progress": 1800,
,
"votes":
"self": "https://jira/rest/api/2/issue/AXL-2766/votes",



]


I've tried but stucked in this:




.[] | issues: .issues, fields: [ .fields .fixVersions .name]




P.S json file can be damaged as I've deleted from there some private info :)







json jq






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 6:50









Inian

40.7k64071




40.7k64071










asked Mar 7 at 6:46









user37033user37033

306




306







  • 1





    You'll need commas between fields (.fields, .fixVersions, .name). Also, what issue are you having?

    – aaaaaa123456789
    Mar 7 at 6:51







  • 1





    Your JSON isn't syntactically valid. Fix it first

    – Inian
    Mar 7 at 6:53











  • @aaaaaa123456789 actually there is no issues, I just need to extract that values from curl output and put them into email message. I don't know how to het multiple values from one , and cannot get name value from fixVersions

    – user37033
    Mar 7 at 7:19












  • First, please fix the JSON. Second, ensure that the example query corresponds to the example JSON, e.g. by specifying each path correctly. Third, reformulate the question so that it is clear what you want done with the fields that are array-valued. Finally, please show the output that you expect your sample query and sample JSON should produce.

    – peak
    Mar 7 at 14:41












  • 1





    You'll need commas between fields (.fields, .fixVersions, .name). Also, what issue are you having?

    – aaaaaa123456789
    Mar 7 at 6:51







  • 1





    Your JSON isn't syntactically valid. Fix it first

    – Inian
    Mar 7 at 6:53











  • @aaaaaa123456789 actually there is no issues, I just need to extract that values from curl output and put them into email message. I don't know how to het multiple values from one , and cannot get name value from fixVersions

    – user37033
    Mar 7 at 7:19












  • First, please fix the JSON. Second, ensure that the example query corresponds to the example JSON, e.g. by specifying each path correctly. Third, reformulate the question so that it is clear what you want done with the fields that are array-valued. Finally, please show the output that you expect your sample query and sample JSON should produce.

    – peak
    Mar 7 at 14:41







1




1





You'll need commas between fields (.fields, .fixVersions, .name). Also, what issue are you having?

– aaaaaa123456789
Mar 7 at 6:51






You'll need commas between fields (.fields, .fixVersions, .name). Also, what issue are you having?

– aaaaaa123456789
Mar 7 at 6:51





1




1





Your JSON isn't syntactically valid. Fix it first

– Inian
Mar 7 at 6:53





Your JSON isn't syntactically valid. Fix it first

– Inian
Mar 7 at 6:53













@aaaaaa123456789 actually there is no issues, I just need to extract that values from curl output and put them into email message. I don't know how to het multiple values from one , and cannot get name value from fixVersions

– user37033
Mar 7 at 7:19






@aaaaaa123456789 actually there is no issues, I just need to extract that values from curl output and put them into email message. I don't know how to het multiple values from one , and cannot get name value from fixVersions

– user37033
Mar 7 at 7:19














First, please fix the JSON. Second, ensure that the example query corresponds to the example JSON, e.g. by specifying each path correctly. Third, reformulate the question so that it is clear what you want done with the fields that are array-valued. Finally, please show the output that you expect your sample query and sample JSON should produce.

– peak
Mar 7 at 14:41





First, please fix the JSON. Second, ensure that the example query corresponds to the example JSON, e.g. by specifying each path correctly. Third, reformulate the question so that it is clear what you want done with the fields that are array-valued. Finally, please show the output that you expect your sample query and sample JSON should produce.

– peak
Mar 7 at 14:41












1 Answer
1






active

oldest

votes


















1














(assuming your json is fixed/valid)



if you're not limited to using jq only, let me offer you an alternative solution: using jtc unix utility it's easy to walk json path (subscripting would look like in a programming language, e.g. similar to Python).



Thus, if your json structure if fixed, then in order to dump all required values provide a walk-path to each of those items:



bash $ jtc -w'[0][issues][0][key]' -w'[0][issues][0][fields][project][self]' -w'[0][issues][0][fields][fixVersions][0][name]' -w'[0][issues][0][fields][fixVersions][0][description]' -w'[0][issues][0][fields][resolution][description]' -w'[0][issues][0][fields][resolution][name]' -w'[0][issues][0][summary]' file.json
"AXL-2766"
"https://jira/rest/api/2/project/15770"
"0.2.0"
"description1"
"description2"
"Fixed"
"summary"
bash $


to shorten the command: a common part of the path [0][issues][0] (which is present in each walk), could be separated out from variable parts, this would produce a shorter cli with the same result:



bash $ jtc -x'[0][issues][0]' -y'[key]' -y'[fields][project][self]' -y'[fields][fixVersions][0][name]' -y'[fields][fixVersions][0][description]' -y'[fields][resolution][description]' -y'[fields][resolution][name]' -y'[summary]' file.json 
"AXL-2766"
"https://jira/rest/api/2/project/15770"
"0.2.0"
"description1"
"description2"
"Fixed"
"summary"
bash $


if your example is only a part of a bigger json (i.e. it's not shown from the root), then replace the initial part ([0][issues][0]) with one employing a search key instead: <issues>l[0].



you could find jtc usage guide here: https://github.com/ldn-softdev/jtc/blob/master/User%20Guide.md






share|improve this answer










New contributor




Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037629%2fjq-parse-json-in-bash%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    (assuming your json is fixed/valid)



    if you're not limited to using jq only, let me offer you an alternative solution: using jtc unix utility it's easy to walk json path (subscripting would look like in a programming language, e.g. similar to Python).



    Thus, if your json structure if fixed, then in order to dump all required values provide a walk-path to each of those items:



    bash $ jtc -w'[0][issues][0][key]' -w'[0][issues][0][fields][project][self]' -w'[0][issues][0][fields][fixVersions][0][name]' -w'[0][issues][0][fields][fixVersions][0][description]' -w'[0][issues][0][fields][resolution][description]' -w'[0][issues][0][fields][resolution][name]' -w'[0][issues][0][summary]' file.json
    "AXL-2766"
    "https://jira/rest/api/2/project/15770"
    "0.2.0"
    "description1"
    "description2"
    "Fixed"
    "summary"
    bash $


    to shorten the command: a common part of the path [0][issues][0] (which is present in each walk), could be separated out from variable parts, this would produce a shorter cli with the same result:



    bash $ jtc -x'[0][issues][0]' -y'[key]' -y'[fields][project][self]' -y'[fields][fixVersions][0][name]' -y'[fields][fixVersions][0][description]' -y'[fields][resolution][description]' -y'[fields][resolution][name]' -y'[summary]' file.json 
    "AXL-2766"
    "https://jira/rest/api/2/project/15770"
    "0.2.0"
    "description1"
    "description2"
    "Fixed"
    "summary"
    bash $


    if your example is only a part of a bigger json (i.e. it's not shown from the root), then replace the initial part ([0][issues][0]) with one employing a search key instead: <issues>l[0].



    you could find jtc usage guide here: https://github.com/ldn-softdev/jtc/blob/master/User%20Guide.md






    share|improve this answer










    New contributor




    Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
























      1














      (assuming your json is fixed/valid)



      if you're not limited to using jq only, let me offer you an alternative solution: using jtc unix utility it's easy to walk json path (subscripting would look like in a programming language, e.g. similar to Python).



      Thus, if your json structure if fixed, then in order to dump all required values provide a walk-path to each of those items:



      bash $ jtc -w'[0][issues][0][key]' -w'[0][issues][0][fields][project][self]' -w'[0][issues][0][fields][fixVersions][0][name]' -w'[0][issues][0][fields][fixVersions][0][description]' -w'[0][issues][0][fields][resolution][description]' -w'[0][issues][0][fields][resolution][name]' -w'[0][issues][0][summary]' file.json
      "AXL-2766"
      "https://jira/rest/api/2/project/15770"
      "0.2.0"
      "description1"
      "description2"
      "Fixed"
      "summary"
      bash $


      to shorten the command: a common part of the path [0][issues][0] (which is present in each walk), could be separated out from variable parts, this would produce a shorter cli with the same result:



      bash $ jtc -x'[0][issues][0]' -y'[key]' -y'[fields][project][self]' -y'[fields][fixVersions][0][name]' -y'[fields][fixVersions][0][description]' -y'[fields][resolution][description]' -y'[fields][resolution][name]' -y'[summary]' file.json 
      "AXL-2766"
      "https://jira/rest/api/2/project/15770"
      "0.2.0"
      "description1"
      "description2"
      "Fixed"
      "summary"
      bash $


      if your example is only a part of a bigger json (i.e. it's not shown from the root), then replace the initial part ([0][issues][0]) with one employing a search key instead: <issues>l[0].



      you could find jtc usage guide here: https://github.com/ldn-softdev/jtc/blob/master/User%20Guide.md






      share|improve this answer










      New contributor




      Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















        1












        1








        1







        (assuming your json is fixed/valid)



        if you're not limited to using jq only, let me offer you an alternative solution: using jtc unix utility it's easy to walk json path (subscripting would look like in a programming language, e.g. similar to Python).



        Thus, if your json structure if fixed, then in order to dump all required values provide a walk-path to each of those items:



        bash $ jtc -w'[0][issues][0][key]' -w'[0][issues][0][fields][project][self]' -w'[0][issues][0][fields][fixVersions][0][name]' -w'[0][issues][0][fields][fixVersions][0][description]' -w'[0][issues][0][fields][resolution][description]' -w'[0][issues][0][fields][resolution][name]' -w'[0][issues][0][summary]' file.json
        "AXL-2766"
        "https://jira/rest/api/2/project/15770"
        "0.2.0"
        "description1"
        "description2"
        "Fixed"
        "summary"
        bash $


        to shorten the command: a common part of the path [0][issues][0] (which is present in each walk), could be separated out from variable parts, this would produce a shorter cli with the same result:



        bash $ jtc -x'[0][issues][0]' -y'[key]' -y'[fields][project][self]' -y'[fields][fixVersions][0][name]' -y'[fields][fixVersions][0][description]' -y'[fields][resolution][description]' -y'[fields][resolution][name]' -y'[summary]' file.json 
        "AXL-2766"
        "https://jira/rest/api/2/project/15770"
        "0.2.0"
        "description1"
        "description2"
        "Fixed"
        "summary"
        bash $


        if your example is only a part of a bigger json (i.e. it's not shown from the root), then replace the initial part ([0][issues][0]) with one employing a search key instead: <issues>l[0].



        you could find jtc usage guide here: https://github.com/ldn-softdev/jtc/blob/master/User%20Guide.md






        share|improve this answer










        New contributor




        Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        (assuming your json is fixed/valid)



        if you're not limited to using jq only, let me offer you an alternative solution: using jtc unix utility it's easy to walk json path (subscripting would look like in a programming language, e.g. similar to Python).



        Thus, if your json structure if fixed, then in order to dump all required values provide a walk-path to each of those items:



        bash $ jtc -w'[0][issues][0][key]' -w'[0][issues][0][fields][project][self]' -w'[0][issues][0][fields][fixVersions][0][name]' -w'[0][issues][0][fields][fixVersions][0][description]' -w'[0][issues][0][fields][resolution][description]' -w'[0][issues][0][fields][resolution][name]' -w'[0][issues][0][summary]' file.json
        "AXL-2766"
        "https://jira/rest/api/2/project/15770"
        "0.2.0"
        "description1"
        "description2"
        "Fixed"
        "summary"
        bash $


        to shorten the command: a common part of the path [0][issues][0] (which is present in each walk), could be separated out from variable parts, this would produce a shorter cli with the same result:



        bash $ jtc -x'[0][issues][0]' -y'[key]' -y'[fields][project][self]' -y'[fields][fixVersions][0][name]' -y'[fields][fixVersions][0][description]' -y'[fields][resolution][description]' -y'[fields][resolution][name]' -y'[summary]' file.json 
        "AXL-2766"
        "https://jira/rest/api/2/project/15770"
        "0.2.0"
        "description1"
        "description2"
        "Fixed"
        "summary"
        bash $


        if your example is only a part of a bigger json (i.e. it's not shown from the root), then replace the initial part ([0][issues][0]) with one employing a search key instead: <issues>l[0].



        you could find jtc usage guide here: https://github.com/ldn-softdev/jtc/blob/master/User%20Guide.md







        share|improve this answer










        New contributor




        Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer








        edited Mar 7 at 9:34





















        New contributor




        Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Mar 7 at 9:21









        DmitryDmitry

        112




        112




        New contributor




        Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Dmitry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037629%2fjq-parse-json-in-bash%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

            Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

            How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page