<?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 CLI API Example json to CSV Export for later use in batch add API commands in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/CLI-API-Example-json-to-CSV-Export-for-later-use-in-batch-add/m-p/38840#M2335</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Overview&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;This CLI API example addresses the answer I was provided to my question, &lt;EM&gt;"&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11pt; font-family: arial,helvetica,sans-serif;"&gt;&lt;EM&gt;Is there a way [easy would be nice], to get the output from a show command to generate a csv output and not a xml style text or json format?&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: arial,helvetica,sans-serif;"&gt;Sensei Uri Bialik provided this excellent example with an overview of how it works, which can be very helpful in designing mgmt_cli show queries in the Gaia CLI [bash] for exporting select configuration values to a CSV file for later import.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Description&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The following command: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;mgmt_cli show services-tcp details-level full limit 500 –root true --format json | $CPDIR/jq/jq '.objects[] | [ .["name"], .["color"], .["comments"], .["port"], .["meta-info"]["last-modifier"] ] | @csv' -r&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Would generate the following csv output:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"MS-SQL-Server","magenta","Microsoft SQL Server","1433","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Yahoo_Messenger_Voice_Chat_TCP","black","Yahoo Messenger Voice Chat","5000-5001","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Bionet-Setup","magenta","Also used by: Blazer5 , Bubbel and Back-door trojans","5000","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"DNP3","sienna","DNP3 is a set of communications protocols used between components in process automation systems. Its main use is in utilities such as electric and water companies","20000","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"indeni","black","Communicate with indeni (&lt;A href="http://www.indeni.com)%22,%228181%22,%22System/"&gt;www.indeni.com)","8181","System&lt;/A&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"FW1_sds_logon_NG","firebrick","SecuRemote Distribution Server Protocol (VC and higher)","65524","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"SocketsdesTroie","deep pink","Also used by the: tcpmux service","1","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"SubSeven-G","magenta","Also used by: Tiles and Backdoor_g trojans","1243","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Mneah","magenta","Mneah trojan","4666","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"SIC-TCP","black","SIC TCP service","18190-19191","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"HTTPS_proxy","navy blue","","8080","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Napster_directory_7777","black","Napster directory connections","7777","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Backage","deep pink","Backage trojan","411","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"CheckPointExchangeAgent","black","","18301","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Terrortrojan","magenta","Terror trojan","3456","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"OPC","sienna","OPC specifies the communication of real-time plant data between control devices from different manufacturers","3480","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Yahoo_Messenger_Webcams","black","Yahoo Messenger Webcams video","5100","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Although the command is a short one I would not go and call it “easy”…&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Anyway this is a very detailed explanation of how this works:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;mgmt_cli show services-tcp details-level full limit 500 --root true --format json&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;This command outputs the list of the first 500 tcp service objects with the maximum level of details.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;I used “--root true” instead of supplying the username and password because I was running the command as root user in expert-mode and as a root user I don’t have to provide username and passwords.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;I used “--format json” to get the output in json format. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;… and now for the tricky part:&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The output of the mgmt_cli command is passed to this command:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;$CPDIR/jq/jq '.objects[] | [ .["name"], .["color"], .["comments"], .["port"], .["meta-info"]["last-modifier"] ] | @csv' -r&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;$CPDIR/jq/jq&lt;/STRONG&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt; : jq is a tool that can do wonders with json data, it can extract the fields you want, filter them and even make a csv out of them.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;“jq” is an open source tool. To learn more about the tool visit: &lt;A href="https://stedolan.github.io/jq/"&gt;https://stedolan.github.io/jq/&lt;/A&gt; , &lt;A href="https://jqplay.org/"&gt;https://jqplay.org/&lt;/A&gt;&amp;nbsp; and this link points to mgmt_cli examples in the&amp;nbsp; Check Point community portal: &lt;A _jive_internal="true" href="https://community.checkpoint.com/message/1151"&gt;https://community.checkpoint.com/message/1151&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;“jq” is now part of Gaia and you can find it in the $CPDIR/jq/ folder.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The “jq” command takes the json information from the mgmt_cli command and decides what to do with this json according to this string:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;'.objects[] | [ .["name"], .["color"], .["comments"], .["port"], .["meta-info"]["last-modifier"] ] | @csv'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;This string is made of 3 steps, each step separated by the “|” character.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;JQ process each step and passes its output as the input for the next step.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #1f497d; text-decoration: underline; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Step 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The json object that we got from the mgmt_cli command looks like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&amp;nbsp; "objects" : [ { data on tcp-object1}, {data on tcp-object 2} , …&amp;nbsp; } ],&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&amp;nbsp; "from" : 1,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&amp;nbsp; "to" : 217,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&amp;nbsp; "total" : 217&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The text “.objects[]”, tells JQ that we’re interested in the objects array and would like to pass the data in that array to the next step.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #1f497d; text-decoration: underline; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Step 2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;[ .["name"], .["color"], .["comments"], .["port"], .["meta-info"]["last-modifier"] ]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;This step takes the tcp-objects and for every tcp-object creates an array with 5 fields.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Notice that the “last-modifier” field is a field inside an object called “meta-data”.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Here’s a screen-shot from &lt;A href="https://jqplay.org/"&gt;&lt;SPAN style="font-size: 12.0pt; color: #1f497d;"&gt;https://jqplay.org/&lt;/SPAN&gt;&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;I copied and pasted the output of the mgmt_cli command in the “json” panel.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The “filter” field holds the text from step1 + step2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The result panel shows the output for the given json and filter.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;IMG alt="Example_filtered_JSON_output.png" class="image-1 jive-image j-img-original" src="https://community.checkpoint.com/legacyfs/online/checkpoint/53235_Example_filtered_JSON_output.png" /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #1f497d; text-decoration: underline; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Step 3:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;This step takes the output of step2 and converts it from a list of arrays (as shown in the result panel in the screen shot) to a csv text file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Each line in the output will now look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: #1f497d;"&gt;"\"MS-SQL-Server\",\"magenta\",\"Microsoft SQL Server\",\"1433\",\"System\""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #1f497d; text-decoration: underline; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Step 4:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Adding the –r at the end of the JQ command removes the redundant “ characters surrounding each line and so lines would now look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: #1f497d;"&gt;"MS-SQL-Server","magenta","Microsoft SQL Server","1433","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Instructions&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;This is a sample one line operation demonstrating the interplay between mgmt_cli API call for object output via show command, and piping json formatted output through jq to a CSV output based on a limited list of object elements to include.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use this example, copy-paste and modify the appropriate sections to suite the needs of your operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While the example is specifically using "show services-tcp", any show operation should be able to utilize the approach, with tailoring in the object element section.&lt;/P&gt;&lt;P&gt;Example (expanded to include authentication with "-s &amp;lt;session_id_file&amp;gt;"):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;mgmt_cli show hosts details-level full limit 250 --format json -s id.txt | $CPDIR/jq/jq '.objects[] | [ .["name"], ["ipv4-address"], .["color"], .["comments"], .["nat-settings"]&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;["auto-rule"]&lt;/STRONG&gt;, .["nat-settings"]["ipv4-address"]&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;, .["nat-settings"]["install-on"]&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;, .["nat-settings"]["method"]&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt; ] | @csv' -r&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Code Version&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Code example version 1.0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Tested on version&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;R80, API version 1.0@&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you to Uri Bialik for providing this very instructive answer and code sample for json to CSV conversion using jq from the Gaia CLI.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 13px; color: #ff0000;"&gt;&lt;STRONG&gt;NOTICE: &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.6667px; color: #999999;"&gt;&lt;STRONG&gt;By using this sample code you agree to terms and conditions in this &lt;A href="https://community.checkpoint.com/docs/DOC-1042"&gt;Not authorized to view the specified document 1042&lt;/A&gt;​&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jun 2016 16:22:48 GMT</pubDate>
    <dc:creator>Eric_Beasley</dc:creator>
    <dc:date>2016-06-29T16:22:48Z</dc:date>
    <item>
      <title>CLI API Example json to CSV Export for later use in batch add API commands</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/CLI-API-Example-json-to-CSV-Export-for-later-use-in-batch-add/m-p/38840#M2335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Overview&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;This CLI API example addresses the answer I was provided to my question, &lt;EM&gt;"&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11pt; font-family: arial,helvetica,sans-serif;"&gt;&lt;EM&gt;Is there a way [easy would be nice], to get the output from a show command to generate a csv output and not a xml style text or json format?&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: arial,helvetica,sans-serif;"&gt;Sensei Uri Bialik provided this excellent example with an overview of how it works, which can be very helpful in designing mgmt_cli show queries in the Gaia CLI [bash] for exporting select configuration values to a CSV file for later import.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Description&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The following command: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;mgmt_cli show services-tcp details-level full limit 500 –root true --format json | $CPDIR/jq/jq '.objects[] | [ .["name"], .["color"], .["comments"], .["port"], .["meta-info"]["last-modifier"] ] | @csv' -r&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Would generate the following csv output:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"MS-SQL-Server","magenta","Microsoft SQL Server","1433","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Yahoo_Messenger_Voice_Chat_TCP","black","Yahoo Messenger Voice Chat","5000-5001","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Bionet-Setup","magenta","Also used by: Blazer5 , Bubbel and Back-door trojans","5000","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"DNP3","sienna","DNP3 is a set of communications protocols used between components in process automation systems. Its main use is in utilities such as electric and water companies","20000","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"indeni","black","Communicate with indeni (&lt;A href="http://www.indeni.com)%22,%228181%22,%22System/"&gt;www.indeni.com)","8181","System&lt;/A&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"FW1_sds_logon_NG","firebrick","SecuRemote Distribution Server Protocol (VC and higher)","65524","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"SocketsdesTroie","deep pink","Also used by the: tcpmux service","1","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"SubSeven-G","magenta","Also used by: Tiles and Backdoor_g trojans","1243","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Mneah","magenta","Mneah trojan","4666","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"SIC-TCP","black","SIC TCP service","18190-19191","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"HTTPS_proxy","navy blue","","8080","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Napster_directory_7777","black","Napster directory connections","7777","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Backage","deep pink","Backage trojan","411","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"CheckPointExchangeAgent","black","","18301","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Terrortrojan","magenta","Terror trojan","3456","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"OPC","sienna","OPC specifies the communication of real-time plant data between control devices from different manufacturers","3480","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;"Yahoo_Messenger_Webcams","black","Yahoo Messenger Webcams video","5100","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; font-family: courier new,courier; color: #1f497d;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Although the command is a short one I would not go and call it “easy”…&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Anyway this is a very detailed explanation of how this works:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;mgmt_cli show services-tcp details-level full limit 500 --root true --format json&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;This command outputs the list of the first 500 tcp service objects with the maximum level of details.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;I used “--root true” instead of supplying the username and password because I was running the command as root user in expert-mode and as a root user I don’t have to provide username and passwords.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;I used “--format json” to get the output in json format. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;… and now for the tricky part:&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The output of the mgmt_cli command is passed to this command:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;$CPDIR/jq/jq '.objects[] | [ .["name"], .["color"], .["comments"], .["port"], .["meta-info"]["last-modifier"] ] | @csv' -r&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;$CPDIR/jq/jq&lt;/STRONG&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt; : jq is a tool that can do wonders with json data, it can extract the fields you want, filter them and even make a csv out of them.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;“jq” is an open source tool. To learn more about the tool visit: &lt;A href="https://stedolan.github.io/jq/"&gt;https://stedolan.github.io/jq/&lt;/A&gt; , &lt;A href="https://jqplay.org/"&gt;https://jqplay.org/&lt;/A&gt;&amp;nbsp; and this link points to mgmt_cli examples in the&amp;nbsp; Check Point community portal: &lt;A _jive_internal="true" href="https://community.checkpoint.com/message/1151"&gt;https://community.checkpoint.com/message/1151&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;“jq” is now part of Gaia and you can find it in the $CPDIR/jq/ folder.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The “jq” command takes the json information from the mgmt_cli command and decides what to do with this json according to this string:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;'.objects[] | [ .["name"], .["color"], .["comments"], .["port"], .["meta-info"]["last-modifier"] ] | @csv'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;This string is made of 3 steps, each step separated by the “|” character.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;JQ process each step and passes its output as the input for the next step.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #1f497d; text-decoration: underline; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Step 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The json object that we got from the mgmt_cli command looks like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&amp;nbsp; "objects" : [ { data on tcp-object1}, {data on tcp-object 2} , …&amp;nbsp; } ],&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&amp;nbsp; "from" : 1,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&amp;nbsp; "to" : 217,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&amp;nbsp; "total" : 217&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The text “.objects[]”, tells JQ that we’re interested in the objects array and would like to pass the data in that array to the next step.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #1f497d; text-decoration: underline; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Step 2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;[ .["name"], .["color"], .["comments"], .["port"], .["meta-info"]["last-modifier"] ]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;This step takes the tcp-objects and for every tcp-object creates an array with 5 fields.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Notice that the “last-modifier” field is a field inside an object called “meta-data”.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Here’s a screen-shot from &lt;A href="https://jqplay.org/"&gt;&lt;SPAN style="font-size: 12.0pt; color: #1f497d;"&gt;https://jqplay.org/&lt;/SPAN&gt;&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;I copied and pasted the output of the mgmt_cli command in the “json” panel.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The “filter” field holds the text from step1 + step2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The result panel shows the output for the given json and filter.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;IMG alt="Example_filtered_JSON_output.png" class="image-1 jive-image j-img-original" src="https://community.checkpoint.com/legacyfs/online/checkpoint/53235_Example_filtered_JSON_output.png" /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #1f497d; text-decoration: underline; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Step 3:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;This step takes the output of step2 and converts it from a list of arrays (as shown in the result panel in the screen shot) to a csv text file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Each line in the output will now look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: #1f497d;"&gt;"\"MS-SQL-Server\",\"magenta\",\"Microsoft SQL Server\",\"1433\",\"System\""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #1f497d; text-decoration: underline; font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Step 4:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Adding the –r at the end of the JQ command removes the redundant “ characters surrounding each line and so lines would now look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: #1f497d;"&gt;"MS-SQL-Server","magenta","Microsoft SQL Server","1433","System"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Instructions&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;This is a sample one line operation demonstrating the interplay between mgmt_cli API call for object output via show command, and piping json formatted output through jq to a CSV output based on a limited list of object elements to include.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use this example, copy-paste and modify the appropriate sections to suite the needs of your operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While the example is specifically using "show services-tcp", any show operation should be able to utilize the approach, with tailoring in the object element section.&lt;/P&gt;&lt;P&gt;Example (expanded to include authentication with "-s &amp;lt;session_id_file&amp;gt;"):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;mgmt_cli show hosts details-level full limit 250 --format json -s id.txt | $CPDIR/jq/jq '.objects[] | [ .["name"], ["ipv4-address"], .["color"], .["comments"], .["nat-settings"]&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;["auto-rule"]&lt;/STRONG&gt;, .["nat-settings"]["ipv4-address"]&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;, .["nat-settings"]["install-on"]&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;&lt;STRONG style="color: #1f497d; font-size: 11.0pt; font-family: 'Courier New';"&gt;, .["nat-settings"]["method"]&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt; ] | @csv' -r&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Code Version&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Code example version 1.0.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Tested on version&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;R80, API version 1.0@&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you to Uri Bialik for providing this very instructive answer and code sample for json to CSV conversion using jq from the Gaia CLI.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 13px; color: #ff0000;"&gt;&lt;STRONG&gt;NOTICE: &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.6667px; color: #999999;"&gt;&lt;STRONG&gt;By using this sample code you agree to terms and conditions in this &lt;A href="https://community.checkpoint.com/docs/DOC-1042"&gt;Not authorized to view the specified document 1042&lt;/A&gt;​&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 16:22:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/CLI-API-Example-json-to-CSV-Export-for-later-use-in-batch-add/m-p/38840#M2335</guid>
      <dc:creator>Eric_Beasley</dc:creator>
      <dc:date>2016-06-29T16:22:48Z</dc:date>
    </item>
  </channel>
</rss>

