<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to parse from nested arrays - API/JQ in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/81172#M4687</link>
    <description>&lt;P&gt;Recently I pulled a CSV using the API on our MDS to see the last policy installation date of gateways within a domain:&lt;/P&gt;&lt;P&gt;mgmt_cli show gateways-and-servers limit 500 offset 0 details-level "full" -d "1.1.1.1" --root true --format json | /opt/CPshrd-R80.30/bin/jq '.objects[] | [ .["name"], .["policy"]["access-policy-name"], .["policy"]["access-policy-installation-date"]["iso-8601"] ] | @csv' -r &amp;gt; csv-policy-installation-date.csv&lt;/P&gt;&lt;P&gt;I'd hoped to modify the jq query to pull the hostnames along with the interface names - a similar query failed because the interface information is part of an array nested inside of the objects array.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I pull the info so I can get the just the names of the gateways and their &lt;EM&gt;associated&lt;/EM&gt;&amp;nbsp;interface details (IP/Mask/Interface-name)?&lt;/P&gt;&lt;P&gt;Example of JSON I'm using on jqplay.org to drive myself to drinking:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
"objects" : [ {
    "name" : "FW1",
    "interfaces" : [ {
      "interface-name" : "WAN",
      "ipv4-address" : "99.99.99.222",
      "ipv4-network-mask" : "255.255.255.252"
    }, {
      "interface-name" : "LAN1",
      "ipv4-address" : "10.99.99.4",
      "ipv4-network-mask" : "255.255.255.240"
    }  ],
    "junk" : "errata"
}, {
    "name" : "FW2",
    "interfaces": [ {
      "interface-name" : "WAN",
      "ipv4-address" : "99.99.99.223",
      "ipv4-network-mask" : "255.255.255.252"
     }, {
      "interface-name" : "LAN1",
      "ipv4-address" : "10.99.99.5",
      "ipv4-network-mask" : "255.255.255.240"
     } ]
} ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 18:06:30 GMT</pubDate>
    <dc:creator>ArtW</dc:creator>
    <dc:date>2020-04-07T18:06:30Z</dc:date>
    <item>
      <title>How to parse from nested arrays - API/JQ</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/81172#M4687</link>
      <description>&lt;P&gt;Recently I pulled a CSV using the API on our MDS to see the last policy installation date of gateways within a domain:&lt;/P&gt;&lt;P&gt;mgmt_cli show gateways-and-servers limit 500 offset 0 details-level "full" -d "1.1.1.1" --root true --format json | /opt/CPshrd-R80.30/bin/jq '.objects[] | [ .["name"], .["policy"]["access-policy-name"], .["policy"]["access-policy-installation-date"]["iso-8601"] ] | @csv' -r &amp;gt; csv-policy-installation-date.csv&lt;/P&gt;&lt;P&gt;I'd hoped to modify the jq query to pull the hostnames along with the interface names - a similar query failed because the interface information is part of an array nested inside of the objects array.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I pull the info so I can get the just the names of the gateways and their &lt;EM&gt;associated&lt;/EM&gt;&amp;nbsp;interface details (IP/Mask/Interface-name)?&lt;/P&gt;&lt;P&gt;Example of JSON I'm using on jqplay.org to drive myself to drinking:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
"objects" : [ {
    "name" : "FW1",
    "interfaces" : [ {
      "interface-name" : "WAN",
      "ipv4-address" : "99.99.99.222",
      "ipv4-network-mask" : "255.255.255.252"
    }, {
      "interface-name" : "LAN1",
      "ipv4-address" : "10.99.99.4",
      "ipv4-network-mask" : "255.255.255.240"
    }  ],
    "junk" : "errata"
}, {
    "name" : "FW2",
    "interfaces": [ {
      "interface-name" : "WAN",
      "ipv4-address" : "99.99.99.223",
      "ipv4-network-mask" : "255.255.255.252"
     }, {
      "interface-name" : "LAN1",
      "ipv4-address" : "10.99.99.5",
      "ipv4-network-mask" : "255.255.255.240"
     } ]
} ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 18:06:30 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/81172#M4687</guid>
      <dc:creator>ArtW</dc:creator>
      <dc:date>2020-04-07T18:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse from nested arrays - API/JQ</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/81803#M4728</link>
      <description>&lt;P&gt;personally this is where I've found simple jq parsing fall short and you need to extend into higher level programming language.&amp;nbsp; if you can export the json and import it to a box with python you can parse this out with a couple of nested loops looking at the length of the json (since in python json = dict native type).&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;lt;code&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;#!/usr/bin/python3 &lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; json&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;to_parse = {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; "objects"&lt;/SPAN&gt;&lt;SPAN&gt; : [ {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "name"&lt;/SPAN&gt;&lt;SPAN&gt; : &lt;/SPAN&gt;&lt;SPAN&gt;"FW1"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "interfaces"&lt;/SPAN&gt;&lt;SPAN&gt; : [ {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"interface-name"&lt;/SPAN&gt;&lt;SPAN&gt; : &lt;/SPAN&gt;&lt;SPAN&gt;"WAN"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"ipv4-address"&lt;/SPAN&gt;&lt;SPAN&gt; : &lt;/SPAN&gt;&lt;SPAN&gt;"99.99.99.222"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"ipv4-network-mask"&lt;/SPAN&gt;&lt;SPAN&gt; : &lt;/SPAN&gt;&lt;SPAN&gt;"255.255.255.252"&lt;/SPAN&gt;&lt;/DIV&gt;&lt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t; x &lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;range&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;len&lt;/SPAN&gt;&lt;SPAN&gt;(to_parse[&lt;/SPAN&gt;&lt;SPAN&gt;'objects'&lt;/SPAN&gt;&lt;SPAN&gt;])):&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print&lt;/SPAN&gt;&lt;SPAN&gt;(to_parse[&lt;/SPAN&gt;&lt;SPAN&gt;'objects'&lt;/SPAN&gt;&lt;SPAN&gt;][x][&lt;/SPAN&gt;&lt;SPAN&gt;'name'&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for&lt;/SPAN&gt;&lt;SPAN&gt; y &lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;range&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;len&lt;/SPAN&gt;&lt;SPAN&gt;(to_parse[&lt;/SPAN&gt;&lt;SPAN&gt;'objects'&lt;/SPAN&gt;&lt;SPAN&gt;][x][&lt;/SPAN&gt;&lt;SPAN&gt;'interfaces'&lt;/SPAN&gt;&lt;SPAN&gt;])):&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print&lt;/SPAN&gt;&lt;SPAN&gt;(to_parse[&lt;/SPAN&gt;&lt;SPAN&gt;'objects'&lt;/SPAN&gt;&lt;SPAN&gt;][x][&lt;/SPAN&gt;&lt;SPAN&gt;'interfaces'&lt;/SPAN&gt;&lt;SPAN&gt;][y][&lt;/SPAN&gt;&lt;SPAN&gt;'interface-name'&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print&lt;/SPAN&gt;&lt;SPAN&gt;(to_parse[&lt;/SPAN&gt;&lt;SPAN&gt;'objects'&lt;/SPAN&gt;&lt;SPAN&gt;][x][&lt;/SPAN&gt;&lt;SPAN&gt;'interfaces'&lt;/SPAN&gt;&lt;SPAN&gt;][y][&lt;/SPAN&gt;&lt;SPAN&gt;'ipv4-address'&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print&lt;/SPAN&gt;&lt;SPAN&gt;(to_parse[&lt;/SPAN&gt;&lt;SPAN&gt;'objects'&lt;/SPAN&gt;&lt;SPAN&gt;][x][&lt;/SPAN&gt;&lt;SPAN&gt;'interfaces'&lt;/SPAN&gt;&lt;SPAN&gt;][y][&lt;/SPAN&gt;&lt;SPAN&gt;'ipv4-network-mask'&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"----------------------------"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"**************************************"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;lt;/code&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;can give an output like :&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;FW1&lt;BR /&gt;WAN&lt;BR /&gt;99.99.99.222&lt;BR /&gt;255.255.255.252&lt;BR /&gt;LAN1&lt;BR /&gt;10.99.99.4&lt;BR /&gt;255.255.255.240&lt;BR /&gt;----------------------------&lt;BR /&gt;FW2&lt;BR /&gt;WAN&lt;BR /&gt;99.99.99.223&lt;BR /&gt;255.255.255.252&lt;BR /&gt;LAN1&lt;BR /&gt;10.99.99.5&lt;BR /&gt;255.255.255.240&lt;BR /&gt;----------------------------&lt;BR /&gt;**************************************&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Apr 2020 13:42:37 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/81803#M4728</guid>
      <dc:creator>Greg_Dunlap</dc:creator>
      <dc:date>2020-04-14T13:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse from nested arrays - API/JQ</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/81829#M4730</link>
      <description>&lt;P&gt;The right way to do it depends on the exact output you want. Here are two examples which process the data from your example JSON:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;$ cat test.json | jq ".objects[]|{name:.name,interfaces:[.interfaces[]|{name:.\"interface-name\"}]}"
{
  "name": "FW1",
  "interfaces": [
    {
      "name": "WAN"
    },
    {
      "name": "LAN1"
    }
  ]
}
{
  "name": "FW2",
  "interfaces": [
    {
      "name": "WAN"
    },
    {
      "name": "LAN1"
    }
  ]
}
$ cat test.json | jq ".objects[]|{name:.name,interfaces:.interfaces[]|.\"interface-name\"}" 
{
  "name": "FW1",
  "interfaces": "WAN"
}
{
  "name": "FW1",
  "interfaces": "LAN1"
}
{
  "name": "FW2",
  "interfaces": "WAN"
}
{
  "name": "FW2",
  "interfaces": "LAN1"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first maintains more of the original structure of the input JSON.&lt;/P&gt;&lt;P&gt;The second is useful for times when you want to break it out into a full description of each individual inner item. Not great for this specific instance, but it would, for example, let you split out rules to each individual source:destination:service combination for mathematical analysis.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 16:17:35 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/81829#M4730</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2020-04-14T16:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse from nested arrays - API/JQ</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/82035#M4733</link>
      <description>&lt;P&gt;Thought I should add an example of how the second could be useful. From this JSON:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
	"rules":[
		{
			"name":"rule1",
			"source":[
				{"name":"SrcA","ipAddress":"10.10.0.1"},
				{"name":"SrcB","ipAddress":"10.10.0.2"},
				{"name":"SrcC","ipAddress":"10.10.0.3"}
			],
			"dest":[
				{"name":"DstD","ipAddress":"10.0.10.1"},
				{"name":"DstE","ipAddress":"10.0.10.2"},
				{"name":"DstF","ipAddress":"10.0.10.3"}
			],
			"service":[
				{"name":"ssh","port":22}
			]
		},{
			"name":"rule2",
			"source":[
				{"name":"SrcW","ipAddress":"10.20.0.1"},
				{"name":"SrcX","ipAddress":"10.20.0.2"}
			],
			"dest":[
				{"name":"DstY","ipAddress":"1.1.1.1"},
				{"name":"DstZ","ipAddress":"1.1.1.2"}
			],
			"service":[
				{"name":"http","port":80},
				{"name":"https","port":443}
			]
		}
	]
}&lt;/LI-CODE&gt;&lt;P&gt;I can break the rules down into individual source:destination:service combinations like so:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;$ cat test.json | jq -c ".rules[]|{name:.name,source:.source[]|.,dest:.dest[]|.,service:.service[]|.}"
{"name":"rule1","source":{"name":"SrcA","ipAddress":"10.10.0.1"},"dest":{"name":"DstD","ipAddress":"10.0.10.1"},"service":{"name":"ssh","port":22}}
{"name":"rule1","source":{"name":"SrcA","ipAddress":"10.10.0.1"},"dest":{"name":"DstE","ipAddress":"10.0.10.2"},"service":{"name":"ssh","port":22}}
{"name":"rule1","source":{"name":"SrcA","ipAddress":"10.10.0.1"},"dest":{"name":"DstF","ipAddress":"10.0.10.3"},"service":{"name":"ssh","port":22}}
{"name":"rule1","source":{"name":"SrcB","ipAddress":"10.10.0.2"},"dest":{"name":"DstD","ipAddress":"10.0.10.1"},"service":{"name":"ssh","port":22}}
{"name":"rule1","source":{"name":"SrcB","ipAddress":"10.10.0.2"},"dest":{"name":"DstE","ipAddress":"10.0.10.2"},"service":{"name":"ssh","port":22}}
{"name":"rule1","source":{"name":"SrcB","ipAddress":"10.10.0.2"},"dest":{"name":"DstF","ipAddress":"10.0.10.3"},"service":{"name":"ssh","port":22}}
{"name":"rule1","source":{"name":"SrcC","ipAddress":"10.10.0.3"},"dest":{"name":"DstD","ipAddress":"10.0.10.1"},"service":{"name":"ssh","port":22}}
{"name":"rule1","source":{"name":"SrcC","ipAddress":"10.10.0.3"},"dest":{"name":"DstE","ipAddress":"10.0.10.2"},"service":{"name":"ssh","port":22}}
{"name":"rule1","source":{"name":"SrcC","ipAddress":"10.10.0.3"},"dest":{"name":"DstF","ipAddress":"10.0.10.3"},"service":{"name":"ssh","port":22}}
{"name":"rule2","source":{"name":"SrcW","ipAddress":"10.20.0.1"},"dest":{"name":"DstY","ipAddress":"1.1.1.1"},"service":{"name":"http","port":80}}
{"name":"rule2","source":{"name":"SrcW","ipAddress":"10.20.0.1"},"dest":{"name":"DstY","ipAddress":"1.1.1.1"},"service":{"name":"https","port":443}}
{"name":"rule2","source":{"name":"SrcW","ipAddress":"10.20.0.1"},"dest":{"name":"DstZ","ipAddress":"1.1.1.2"},"service":{"name":"http","port":80}}
{"name":"rule2","source":{"name":"SrcW","ipAddress":"10.20.0.1"},"dest":{"name":"DstZ","ipAddress":"1.1.1.2"},"service":{"name":"https","port":443}}
{"name":"rule2","source":{"name":"SrcX","ipAddress":"10.20.0.2"},"dest":{"name":"DstY","ipAddress":"1.1.1.1"},"service":{"name":"http","port":80}}
{"name":"rule2","source":{"name":"SrcX","ipAddress":"10.20.0.2"},"dest":{"name":"DstY","ipAddress":"1.1.1.1"},"service":{"name":"https","port":443}}
{"name":"rule2","source":{"name":"SrcX","ipAddress":"10.20.0.2"},"dest":{"name":"DstZ","ipAddress":"1.1.1.2"},"service":{"name":"http","port":80}}
{"name":"rule2","source":{"name":"SrcX","ipAddress":"10.20.0.2"},"dest":{"name":"DstZ","ipAddress":"1.1.1.2"},"service":{"name":"https","port":443}}&lt;/LI-CODE&gt;&lt;P&gt;This form of rule is ripe for optimization (that is, finding an efficient way to build rules or groups to reduce or eliminate duplication). You can also apply graph theory to find out if there's some other SrcD which has very similar access, but is missing from rule1.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 18:30:32 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/How-to-parse-from-nested-arrays-API-JQ/m-p/82035#M4733</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2020-04-15T18:30:32Z</dc:date>
    </item>
  </channel>
</rss>

