<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ssis xml parser transform Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/tag/ssis-xml-parser-transform/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/tag/ssis-xml-parser-transform/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Wed, 11 Dec 2024 15:24:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.4</generator>

<image>
	<url>https://zappysys.com/blog/wp-content/uploads/2023/01/cropped-zappysys-symbol-large-32x32.png</url>
	<title>ssis xml parser transform Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/tag/ssis-xml-parser-transform/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to import XML into SQL Server using SSIS</title>
		<link>https://zappysys.com/blog/ssis-import-xml-file-sql-server-parse-xml/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Tue, 30 Aug 2016 22:42:05 +0000</pubDate>
				<category><![CDATA[SSIS XML Source (File / SOAP)]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[ssis xml parser transform]]></category>
		<category><![CDATA[ssis xml source]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=755</guid>

					<description><![CDATA[<p>Introduction In this post you will learn how to import XML file into target such as SQL Server, CSV, Excel, Oracle. Converting or Importing XML requires flattening XML structure (i.e. hierarchy) sometimes we refer this process as de-normalization.  Parsing XML can be tricky depending on how many levels you have and from which level you need data. [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/ssis-import-xml-file-sql-server-parse-xml/">How to import XML into SQL Server using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2016/08/ssis-xml-parser-transform.png"><img decoding="async" class="alignleft wp-image-2122" src="https://zappysys.com/blog/wp-content/uploads/2016/08/ssis-xml-parser-transform.png" alt="" width="90" height="90" /></a>In this post you will learn how to import XML file into target such as SQL Server, CSV, Excel, Oracle. Converting or Importing XML requires flattening XML structure (i.e. hierarchy) sometimes we refer this process as de-normalization.  Parsing XML can be tricky depending on how many levels you have and from which level you need data. If you want to <a href="//zappysys.com/blog/tutorial-create-xml-in-ssis-export-xml-file-output/" target="_blank" rel="noopener">export XML rather than Import then check this article</a>.</p>
<p>This article assumes you have installed <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener"><span style="color: #248cc8;">SSIS PowerPack</span></a> and watched introduction videos of <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener"><span style="color: #248cc8;">SSIS XML Source Connector</span></a> and <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-parser-transform/" target="_blank" rel="noopener"><span style="color: #248cc8;">SSIS XML Parser Transform</span></a></p>
<h2>Import XML File using SSIS XML Source</h2>
<p>ZappySys <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener"><span style="color: #248cc8;">SSIS XML Source </span></a>is a very powerful component. It supports not only reading from file but also reading from Direct XML String or <a href="https://zappysys.com/blog/calling-soap-web-service-in-ssis-xml-source/" target="_blank" rel="noopener">REST API / SOAP Web Service.</a></p>
<h3>How ZappySys XML Source parse/output data</h3>
<p><a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener"><span style="color: #248cc8;">XML Source</span></a> created by ZappySys is very different than what Microsoft provides out the box because ZappySys component outputs one flat view of nested XML document (de-normalized) compared to many outputs what Microsoft XML Source produces which is hard to manage and join based on relation with parent node.</p>
<p>With ZappySys XML component you don&#8217;t have to worry about joins because by default parent columns included along with hierarchy you extracted (e.g. If you extract $.Customer.Orders[*].OrderDetails[*] then you get all columns listed under &lt;Order&gt; and &lt;Customer&gt; nodes)</p>
<div style="width: 716px" class="wp-caption alignnone"><img fetchpriority="high" decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-data-from-path-or-web-url-variable.png" alt="SSIS XML Source - Variable Mode - Call Web API or Read from File" width="706" height="461" /><p class="wp-caption-text">ZappySys XML Source (Read XML Files, Consume REST API, SOPA Web Service)</p></div>
<h3>Importing single or multiple XML Files</h3>
<p>To import single files specify full XML file path</p>
<p>Example:  c:\ssis\<strong>File_001.xml</strong></p>
<p>To import multiple files using XML source use wildcard pattern</p>
<p>Example:  c:\ssis\<strong>File_*.xml</strong></p>
<div style="width: 653px" class="wp-caption alignnone"><img loading="lazy" decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-read-from-multiple-files.png" alt="SSIS XML Source - Read data from XML files (Single or Multiple files) - Use wildcard pattern in path" width="643" height="230" /><p class="wp-caption-text">XML File Source &#8211; Specify File Path with wildcard pattern (Loop multiple files)</p></div>
<div style="width: 659px" class="wp-caption alignnone"><img loading="lazy" decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-read-multiple-files-wildcard-pattern.png" alt="SSIS XML Source - Read data from XML files (Single or Multiple files) - Use wildcard pattern in path" width="649" height="318" /><p class="wp-caption-text">Importing data from multiple XML files</p></div>
<p>&nbsp;</p>
<h3>Using variable to make path dynamic</h3>
<p>You can also use variable placeholders in your path to make it dynamic</p>
<p>Example:  c:\ssis\<strong>{{User::FileName}}</strong>.xml</p>
<h2>Importing data from XML Web Service or REST API</h2>
<p>XML Source supports consuming REST API data or calling XML SOAP Web services. This article doesn&#8217;t include this feature in depth. But refer to learn more about this feature.</p>
<div style="width: 714px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="figureimage" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-data-from-web-url.png" alt="SSIS XML Source - Direct Mode - Call REST API web service or read from XML File" width="704" height="595" /><p class="wp-caption-text">SSIS XML Source &#8211; Direct Mode &#8211; Call REST API web service or read from XML File</p></div>
<p>&nbsp;</p>
<h2>Parse XML string and split into columns using XML Parser Transform</h2>
<div style="width: 831px" class="wp-caption alignnone"><img loading="lazy" decoding="async" title="SSIS XML Parser Transform - Parse XML Document, Convert XML to CSV or save to RDBMS (e.g. SQL Server, MySQL)" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-parser-transform/ssis-xml-parser-transform-convert-xml-to-csv.png" alt="SSIS XML Parser Transform - Parse XMl Document, Convert XML to CSV or save to RDBMS (e.g. SQL Server, MySQL)" width="821" height="643" /><p class="wp-caption-text">Parsing XML Data &#8211; XML String into Columns using SSIS XML Parser Transform</p></div>
<p>&nbsp;</p>
<h2>Other Settings (XML Source, XML Parser Transform)</h2>
<h3>Preview Data</h3>
<p>All access modes support preview data like below. Change your settings such as Filter expression, Source etc and click preview.</p>
<div style="width: 749px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="figureimage" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-data-read-from-direct-string.png" alt="Read XML data in SSIS" width="739" height="586" /><p class="wp-caption-text">Preview XML Data</p></div>
<h3>Filtering data using expression</h3>
<p>You can filter XML data by specifying simple expressions (e.g. $.store.book[*]) to navigate various parts of XML where you can extract data (See above screenshot).</p>
<p>Things to remember for filter expressions</p>
<ul>
<li>Expression must start with $ (means root from where parsing will start)</li>
<li>Use dot (.) to separate Hierarchy and use brackets to indicate array []</li>
<li>Use * to indicate all records</li>
</ul>
<h3>Sample XML for examples</h3>
<pre class="crayon-plain-tag">&lt;?xml version="1.0"?&gt;
&lt;Root Ver="1"&gt;
  &lt;DocInfo&gt;
    &lt;Author&gt;Bob&lt;/Author&gt;
    &lt;Date&gt;2015-01-01&lt;/Date&gt;
    &lt;Location&gt;
      &lt;City&gt;Atlanta&lt;/City&gt;
      &lt;State&gt;GA&lt;/State&gt;
    &lt;/Location&gt;
  &lt;/DocInfo&gt;
  &lt;Customer CustId="1"&gt;
    &lt;Order OrderId="1000"&gt;
      &lt;OrderDate&gt;2005-02-01T10:00:09&lt;/OrderDate&gt;
      &lt;Item ProdId="101"&gt;
        &lt;ProdName&gt;Tea&lt;/ProdName&gt;
      &lt;/Item&gt;
      &lt;Item ProdId="102"&gt;
        &lt;ProdName&gt;Coffee&lt;/ProdName&gt;
      &lt;/Item&gt;
    &lt;/Order&gt;
    &lt;Order OrderId="1001"&gt;
      &lt;OrderDate&gt;2005-04-01T21:59:20&lt;/OrderDate&gt;
      &lt;Item ProdId="101"&gt;
        &lt;ProdName&gt;Tea&lt;/ProdName&gt;
      &lt;/Item&gt;
      &lt;Item&gt;
        &lt;ProdId&gt;201&lt;/ProdId&gt;
        &lt;ProdName&gt;Soda&lt;/ProdName&gt;
      &lt;/Item&gt;
    &lt;/Order&gt;
  &lt;/Customer&gt;
  &lt;Customer CustId="2"&gt;
    &lt;Order OrderId="2000"&gt;
      &lt;OrderDate&gt;2005-02-01T21:59:20&lt;/OrderDate&gt;
      &lt;Item ProdId="301"&gt;
        &lt;ProdName&gt;Apple&lt;/ProdName&gt;
      &lt;/Item&gt;
      &lt;Item ProdId="302"&gt;
        &lt;ProdName&gt;Orange&lt;/ProdName&gt;
      &lt;/Item&gt;
    &lt;/Order&gt;
    &lt;Order OrderId="2001"&gt;
      &lt;OrderDate&gt;2005-01-01T21:59:20&lt;/OrderDate&gt;
      &lt;Item ProdId="201"&gt;
        &lt;ProdName&gt;Soda&lt;/ProdName&gt;
      &lt;/Item&gt;
      &lt;Item ProdId="202"&gt;
        &lt;ProdName&gt;Milk&lt;/ProdName&gt;
      &lt;/Item&gt;
    &lt;/Order&gt;
  &lt;/Customer&gt;  
&lt;/Root&gt;</pre>
<h3>Example of filter expression</h3>
<div class="su-table su-table-alternate">
<table class="props">
<tbody>
<tr>
<th class="columnName">Filter</th>
<th class="columnDesc">Output</th>
</tr>
<tr>
<td>
<pre class="crayon-plain-tag">$</pre>
</td>
<td>Get all records<br />
<img decoding="async" class="figureimage" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-output-example-1.png" alt="SSIS XML Source Adpater - XMLPath filter" /></td>
</tr>
<tr>
<td>$.Root.Customer[*]</td>
<td>Get all customers<br />
<img decoding="async" class="figureimage" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-output-example-4.png" alt="SSIS XML Source Adpater - XMLPath filter" /></td>
</tr>
<tr>
<td>$.Root.Customer[*].Order[*]</td>
<td>Get all orders for all customers<br />
<img decoding="async" class="figureimage" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-output-example-2.png" alt="SSIS XML Source Adpater - XMLPath filter" /></td>
</tr>
<tr>
<td>$.Root.Customer[*].Order[*](Include Parent Columns=True)</td>
<td>Get all orders for all customers (Include Parent Columns option checked)<br />
<img decoding="async" class="figureimage" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-output-example-3-with-parent-columns.png" alt="SSIS XML Source Adpater - XMLPath filter" /></td>
</tr>
<tr>
<td>$.Root.Customer[*].@CustId</td>
<td>Get only Customer Id for each customer record</td>
</tr>
<tr>
<td>$.Root.Customer[*].Order[:1]</td>
<td>Get first order for each customer</td>
</tr>
<tr>
<td>$.Root.Customer[*].Order[:3]</td>
<td>Get top 3 orders for each customer</td>
</tr>
<tr>
<td>$.Root.Customer[*].Order[:1]</td>
<td>Get last order of each customer</td>
</tr>
<tr>
<td>$.Root.Customer[*].Order[0,4]</td>
<td>Get orders starting from first row to fifth row (Zero based index). If you want 5th row to 10th row then use [4,9]</td>
</tr>
<tr>
<td>$.Root.Customer[*].Order[2]</td>
<td>Get 3rd order for each customer</td>
</tr>
</tbody>
</table>
</div>
<h3>Defining array elements</h3>
<p>Any hierarchy you extracting with array indicator can be added to array element name list (On Array handling Tab). This helps when you only have one row for node specified as array.</p>
<p>For example if your filter expression is $.Customer.Order[*].OrderItem[*] in this case you indicated that you can have one or more Order nodes under Customer and you may have one or more OrderItem nodes under Order node. If this is the case then set array handling as below</p>
<div id="attachment_763" style="width: 656px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/08/ssis-xml-array-handling.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-763" class="size-full wp-image-763" src="//zappysys.com/blog/wp-content/uploads/2016/08/ssis-xml-array-handling.png" alt="Handling Rows/Array Elements (Repeated XML Elements) " width="646" height="231" srcset="https://zappysys.com/blog/wp-content/uploads/2016/08/ssis-xml-array-handling.png 646w, https://zappysys.com/blog/wp-content/uploads/2016/08/ssis-xml-array-handling-300x107.png 300w" sizes="(max-width: 646px) 100vw, 646px" /></a><p id="caption-attachment-763" class="wp-caption-text">Handling Rows/Array Elements (Repeated XML Elements)</p></div>
<h3>Editing Column Metadata (Length and DataType)</h3>
<p>XML Source and XML Parser both detects Datatype/Length by scanning sample data (Default 300 rows) but sometimes this is not accurate and it may produce invalid metadata. If that&#8217;s the case you can easily change it in Columns tab. Once you edit Length or DataType make sure you <strong>check Lock column (Last column in grid).</strong> Once Lock is applied metadata refresh wont affect your changes. You can also add new column manually if its not detected (Lets say your XML is very large and many columns not found in first 300 rows scanned). To add new column type in the last grid row or click new icon in the grid toolbar.</p>
<div style="width: 660px" class="wp-caption alignnone"><img loading="lazy" decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/xml-source/ssis-xml-source-select-output-columns.png" alt="SSIS XML Source - Configure Columns and DataType" width="650" height="499" /><p class="wp-caption-text">Edit XML File Source Column Metadata</p></div>
<h2>Conclusion</h2>
<p>In this post you have seen how to use  <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener"><span style="color: #248cc8;">SSIS XML Source Connector</span></a> and <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-parser-transform/" target="_blank" rel="noopener"><span style="color: #248cc8;">SSIS XML Parser Transform</span></a> to extract data from nested XML documents without any coding.</p>
<p><strong>Related to:</strong> SSIS Import XML Files | SSIS Parse XML data | SSIS Extract from XML files | Read from XML Files</p>
<p>The post <a href="https://zappysys.com/blog/ssis-import-xml-file-sql-server-parse-xml/">How to import XML into SQL Server using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Reading JSON Arrays from file / REST API</title>
		<link>https://zappysys.com/blog/extract-read-multiple-arrays-from-json-data-file-rest-api-response/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Mon, 11 Jan 2016 16:50:48 +0000</pubDate>
				<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[json source]]></category>
		<category><![CDATA[jsonpath]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis json parser transform]]></category>
		<category><![CDATA[ssis json source]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[ssis xml parser transform]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=298</guid>

					<description><![CDATA[<p>Introduction REST API is becoming more and more common and with that you will see explosion in use of JSON data format. One of the questions we get a lot is &#8220;How to extract or read array from JSON data file&#8221; or &#8220;How to read multiple arrays from JSON data&#8220;. Example : Store JSON document [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/extract-read-multiple-arrays-from-json-data-file-rest-api-response/">Reading JSON Arrays from file / REST API</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2016/01/SSIS-Json-Source-Adapter.png"><img loading="lazy" decoding="async" class="size-full wp-image-3074 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2016/01/SSIS-Json-Source-Adapter.png" alt="" width="100" height="100" /></a><a href="https://en.wikipedia.org/wiki/Representational_state_transfer" target="_blank" rel="noopener">REST API</a> is becoming more and more common and with that you will see explosion in use of JSON data format. One of the questions we get a lot is &#8220;<em>How to extract or read array from JSON data file</em>&#8221; or &#8220;<em>How to read multiple arrays from JSON data</em>&#8220;. Example : Store JSON document has Customers[&#8230;] and Employees[&#8230;] arrays and lets say you want to extract both and save to target SQL server database. In this post you will learn how to make this possible and how to make it fast with some performance tips. We will use <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">SSIS JSON Source (File, REST API Connector)</a></p>
<p>If you want to learn how to parse Multi-Dimensional JSON arrays then check <a href="//zappysys.com/blog/parse-multi-dimensional-json-array-ssis/" target="_blank" rel="noopener">this article</a>.</p>
<h2>Video Tutorial &#8211; Read from multiple arrays from JSON document</h2>
<a href="https://zappysys.com/blog/extract-read-multiple-arrays-from-json-data-file-rest-api-response/"><img decoding="async" src="https://zappysys.com/blog/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FOt7z8BIFbis%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br /></p>
<h2>Read array from JSON document</h2>
<p>To extract subdocument or array content from JSON document you need to use <strong>JSON Path</strong> expression. Lets check following example JSON document.</p><pre class="crayon-plain-tag">{
  "store": {
    "employees": [
      {
        "name": "bob",
        "hiredate": "2015-01-01"
      },
      {
        "name": "sam",
        "hiredate": "2015-01-02"
      },
      {
        "name": "ken",
        "hiredate": "2015-01-03"
      }
    ],
    "books": [
      {
        "category": "reference",
        "author": "bob",
        "title": "hellooo1",
        "price": 1.95,
        "sections": [
          "s1",
          "s2",
          "s3"
        ]
      },
      {
        "category": "fiction",
        "author": "sam",
        "title": "hellooo2",
        "price": 1.96,
        "sections": [
          "s4",
          "s1",
          "s3"
        ]
      },
      {
        "category": "science",
        "author": "steve",
        "title": "hellooo3",
        "tag": "1bcd",
        "price": 11,
        "sections": [
          "s9",
          "s2",
          "s3"
        ]
      }
    ],
    "location": {
      "street": "123 Main St.",
      "city": "Newyork",
      "state": "GA"
    }
  }
}</pre><p>
Below is example filter expression to extract common elements</p><pre class="crayon-plain-tag">$.store.books[*]       //get all books for store              
$.store.employees[*]       //get all employees for store                 
$.store.books[*].sections[*]       //get all sections from all books   
$.store.books[*].author //get all authors of all books for store           
$.store.books[*]    //get all books for store  
$.store.books[2]    //get 3rd book record
$.store.books[:2]   //get first 2 books from the top
$.store.books[-2:]  //get last 2 books
$.store.books[?(@.price &lt; 10)] //get books where price is less than 10
$.store.books[?(@.tag)] //filter all books with tag</pre><p>
<h2>Read single array from JSON data (JSON Path expression)</h2>
<p>SSIS PowerPack comes with powerful REST API Connectors for <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">JSON</a> and <a href="https://zappysys.com/products/ssis-powerpack/ssis-xml-source/">XML </a> . In below example screenshot you will see how to extract single array section from your JSON File. But if you have multiple array sections (e.g. books and employees from above example) then you have to use Multiple JSON Source Connectors for same JSON File.</p>
<p><img decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-source/ssis-json-source-data-read-from-file-url.png" alt="Read Json File data from Web Url Example in SSIS" /></p>
<h2>Read multiple arrays from JSON data</h2>
<p>If you have scenario to extract multiple arrays from same JSON (e.g. extract Employees and Books from store ) then you have two options. You can pick any approach which suites your need (Method-1 is recommended).</p>
<ol>
<li>Method-1: Use single JSON Source with [Output As Document] option and feed that to <a href="//zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">JSON Parser Transform</a></li>
<li>Method-2: Use multiple JSON Sources with different filter expressions</li>
<li>Method-3: Enable <strong>Array Flattening</strong> Option (Useful if you have smaller arrays &#8211; i.e. less than 10 items) &#8211; <strong>Version v2.7.6+</strong></li>
</ol>
<p>Now lets discuss each approach in detail.</p>
<h3>Method-1: Use single JSON Source along with JSON Parser Transform</h3>
<p><a href="//zappysys.com/onlinehelp/ssis-powerpack/scr/release-notes.htm#v2_2" target="_blank" rel="noopener">SSIS PowerPack v2.2</a> released new <a href="//zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">JSON Parser Transform</a> and <a href="//zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">XML Parser Transform</a> which can be used to parse any input JSON/XML data coming from upstream in pipeline. It parse input string  column into multiple columns how JSON/XML Source does but the only difference is JSON Parser takes String as input from existing upstream column.</p>
<p>Here are the steps to parse multiple JSON arrays using JSON Parser Transform. For example purpose we will use sample store json listed above.</p>
<ol>
<li>Drag new data flow in SSIS Control Flow designer. Double click on Data flow<br />
<img decoding="async" class="figureimage" title="SSIS Data Flow Task - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/drag-and-drop-data-flow-task.png" alt="SSIS Data Flow Task - Drag and Drop" /></li>
<li>Drag ZS JSON Source from SSIS Toolbox. Configure Source, Filter and other property.<br />
<img decoding="async" class="figureimage" title="SSIS JSON Source - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-source/ssis-json-source-adapter-drag.png" alt="SSIS JSON Source - Drag and Drop" /></li>
<li>Check [<strong>Output As Document</strong>] option (Found under Access Mode dropdown). Click preview. From grid <strong>copy one sample document from __DOCUMENT__ column</strong>. (Right click on Cell and Copy).This is raw JSON which we will use later to feed as sample in JSON Parser Transform (If you cant copy JSON then obtain some other way)
<div id="attachment_9175" style="width: 627px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-output-row-document-option.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9175" class="size-full wp-image-9175" src="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-output-row-document-option.png" alt="Enable Output As Raw Document Option - SSIS JSON Source" width="617" height="753" srcset="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-output-row-document-option.png 617w, https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-output-row-document-option-246x300.png 246w" sizes="(max-width: 617px) 100vw, 617px" /></a><p id="caption-attachment-9175" class="wp-caption-text">Enable Output As Raw Document Option &#8211; SSIS JSON Source</p></div></li>
<li>Click OK to save JSON Source.</li>
<li>Drag Multicast Transform (Native SSIS Transform) from Toolbox
<div id="attachment_9174" style="width: 546px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-toolbox-drag-multicast-transform.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9174" class="size-full wp-image-9174" src="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-toolbox-drag-multicast-transform.png" alt="Drag &amp; Drop SSIS MultiCast Transform from Toolbox on designer surface" width="536" height="204" srcset="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-toolbox-drag-multicast-transform.png 536w, https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-toolbox-drag-multicast-transform-300x114.png 300w" sizes="(max-width: 536px) 100vw, 536px" /></a><p id="caption-attachment-9174" class="wp-caption-text">Drag &amp; Drop SSIS MultiCast Transform from Toolbox on designer surface</p></div></li>
<li>Connect JSON Source to Multicast Transform</li>
<li>Drag first <a href="//zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">JSON Parser Transform</a> from Toolbox. Rename it to [Parse Employees]. Connect blue arrow coming from Multicast to JSON Parser Transform</li>
<li>Drag second <a href="//zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">JSON Parser Transform</a> from Toolbox. Rename it to [Parse Books]. Connect blue arrow coming from Multicast to JSON Parser Transform</li>
<li>Double click [Parse Employees]. Select <strong>__DOCUMENT__</strong> as upstream column. Enter sample JSON you obtained in step#3. Click on select Filter and highlight Employees node (i.e. $.store.employees[*] ). Click preview to see data.
<div id="attachment_2399" style="width: 714px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-json-parser-transform-configuration.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2399" class="size-full wp-image-2399" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-json-parser-transform-configuration.png" alt="Use JSON Parser Transform to parse Elasticsearch API HTTP JSON response into columns to redirect the rows later" width="704" height="622" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-json-parser-transform-configuration.png 704w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-json-parser-transform-configuration-300x265.png 300w" sizes="(max-width: 704px) 100vw, 704px" /></a><p id="caption-attachment-2399" class="wp-caption-text">Use <em>JSON Parser Transform</em> to parse Raw JSON document</p></div></li>
<li><strong>Very Important:</strong>Click Columns tab and verify metadata (e.g. datatype, length). If you think you need extra columns or bigger column length then change in the grid and check [Lock] option found in the last grid column. If column length is smaller than output data then you will get error message when you run package. You can review error message carefully to determine which column needs to be adjusted  (Repeat this until you clear all errors).</li>
<li>Click OK to save [Parse Employees].</li>
<li>Double click [Parse Books]. Select __DOCUMENT__ as upstream column. Enter sample JSON you obtained in step#3. Click on select Filter and highlight Books node (i.e. $.store.books[*] ). Click ok. Click preview to see data.</li>
<li>Perform same steps as #11 for  [Parse Books] to set correct metadata.</li>
<li>Click OK to save [Parse Books].</li>
<li>Drag ZS Trash destination from Toolbox. Connect Trash destination to [Parse Employees]</li>
<li>Drag ZS Trash destination from Toolbox. Connect Trash destination to [Parse Books]</li>
<li>Run the package and you will see both 2 outputs from different JSON Parser with different row count.</li>
</ol>
<p>Here is how it will look like</p>
<div style="width: 789px" class="wp-caption alignnone"><img loading="lazy" decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-parser-transform/ssis-json-extract-multiple-array-output-using-parser.png" alt="Extract multiple array output from JSON file / REST API response in (SSIS JSON Source, JSON Parser Transform)" width="779" height="555" /><p class="wp-caption-text">Extract multiple array output from JSON file / REST API response in (SSIS JSON Source, JSON Parser Transform)</p></div>
<p>&nbsp;</p>
<h3>Method-2: Use multiple JSON Sources with different filter expressions</h3>
<p>You can consider using multiple JSON Source (each source with unique filter expression). Since one JSON source can only extract one array or Document.. You have to use below technique to read multiple arrays from same JSON document.</p>
<div id="attachment_322" style="width: 601px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/01/read-multiple-array-from-json-data-file.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-322" class="size-full wp-image-322" src="//zappysys.com/blog/wp-content/uploads/2016/01/read-multiple-array-from-json-data-file.png" alt="Read array from JSON data - Reading multiple array or single array" width="591" height="293" srcset="https://zappysys.com/blog/wp-content/uploads/2016/01/read-multiple-array-from-json-data-file.png 591w, https://zappysys.com/blog/wp-content/uploads/2016/01/read-multiple-array-from-json-data-file-300x149.png 300w" sizes="(max-width: 591px) 100vw, 591px" /></a><p id="caption-attachment-322" class="wp-caption-text">Read array from JSON data &#8211; Reading multiple array or single array</p></div>
<h3>Method-3: Use Array Flattening Option (Preferred for smaller arrays)</h3>
<p>If you have array inside extracted record and you like to flatten it so each items of array becomes column then use newly introduced feature [<strong>Enable Array Flattening</strong>]
<p>Consider JSON like below. What if you don&#8217;t like to store every detail from below JSON in just one table (i.e. rather than splitting in 3 tables Customers, CustomerHobbies , CustomerAddresses ?) . To achieve full denormalization ZappySys offers powerful yet simple one click option.</p><pre class="crayon-plain-tag">{
	"Customer" : [{
			"Name" : "John",
			"Hobby" : ["Painting","Reading","Swimming"],
			"Addresses" : [
				{"Street":"100 Main St","ZipCode":"10062"}, 
				{"Street":"101 Fire St","ZipCode":"11121"}
			]
		}, {
			"Name" : "Peter",
			"Hobby" : ["Hiking","Golf"],
			"Addresses" : [
				{"Street":"200 Main St","ZipCode":"20062"}, 
				{"Street":"201 Fire St","ZipCode":"33321"}
			]
		}
	]
}</pre><p>
To enable flattening check below option on Filter</p>
<div id="attachment_4760" style="width: 857px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/01/json-array-flattening-option.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4760" class="size-full wp-image-4760" src="https://zappysys.com/blog/wp-content/uploads/2016/01/json-array-flattening-option.png" alt="JSON Array Flattening Option in SSIS JSON Source " width="847" height="551" srcset="https://zappysys.com/blog/wp-content/uploads/2016/01/json-array-flattening-option.png 847w, https://zappysys.com/blog/wp-content/uploads/2016/01/json-array-flattening-option-300x195.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/01/json-array-flattening-option-768x500.png 768w" sizes="(max-width: 847px) 100vw, 847px" /></a><p id="caption-attachment-4760" class="wp-caption-text">JSON Array Flattening Option in SSIS JSON Source</p></div>
<p>&nbsp;</p>
<div id="attachment_4761" style="width: 454px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-columns-denormalize-array-option.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4761" class="size-full wp-image-4761" src="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-columns-denormalize-array-option.png" alt="Column after Array Flattening Option" width="444" height="443" srcset="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-columns-denormalize-array-option.png 444w, https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-columns-denormalize-array-option-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-json-source-columns-denormalize-array-option-300x300.png 300w" sizes="(max-width: 444px) 100vw, 444px" /></a><p id="caption-attachment-4761" class="wp-caption-text">Column after Array Flattening Option</p></div>
<p>&nbsp;</p>
<h2>Using JSON REST API Connector to parse JSON data</h2>
<p>If you want to access JSON data from REST API then you can use same JSON Source Connector.  All you have to do is rather than local file path c:\data\xyz.json change it to URL as below and you will be able to access and filter JSON data using same technique as above.</p>
<div style="width: 657px" class="wp-caption alignnone"><a href="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-source/ssis-json-source-data-from-web-url.png"><img loading="lazy" decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-source/ssis-json-source-data-from-web-url.png" alt="Get JSON data from URL (REST API JSON response)" width="647" height="574" /></a><p class="wp-caption-text">Get JSON data from URL (REST API JSON response)</p></div>
<h2>JSON Path for recursive data extract (Double dot expression)</h2>
<p>There will be a time when you dont know how many levels deep you have to go for data extract. See below example. We will to get all employees id and name from hierarchy. For that you can use double dot like below. As you can see there are many nested levels and we want to extract id and name from each level so data can be</p>
<p><strong>Expected Output</strong></p><pre class="crayon-plain-tag">id      name
-------------------------
100	Jeff (CEO)
200	Bob (VP Sales)
300	Kim (VP HR)
400	Kumar (VP Dev)
210	Ron (Sales Mgr)	
220	Akash (Sales Mgr)	
410	Den (Sr. Dev)	
420	Den (Sr. Dev)
411	Den (Jr. Dev)
412	Sita (Jr. Dev)</pre><p>
<strong>Sample Data</strong></p><pre class="crayon-plain-tag">{
  "employees": [
    {
      "id": 100,
      "name": "Jeff (CEO)",
      "employees": [
        {
          "id": 200,
          "name": "Bob (VP Sales)",
          "employees": [
            {
              "id": 210,
              "name": "Ron (Sales Mgr)"
            },
            {
              "id": 220,
              "name": "Akash (Sales Mgr)"
            }
          ]
        },
        {
          "id": 300,
          "name": "Kim (VP HR)"
        },
        {
          "id": 400,
          "name": "Kumar (VP Dev)",
          "employees": [
            {
              "id": 410,
              "name": "Den (Sr. Dev)",
              "employees": [
                {
                  "id": 411,
                  "name": "Den (Jr. Dev)"
                },
                {
                  "id": 412,
                  "name": "Sita (Jr. Dev)"
                }
              ]
            },
            {
              "id": 420,
              "name": "Den (Sr. Dev)"
            }
          ]
        }
      ]
    }
  ]
}</pre><p>
<strong>Configure JSON Source for Recursive Children Scan using Double Dot JSONPath</strong></p>
<p>Open JSON Source and configure like below.</p>
<p>Set Filter as $..employees[*] (Notice how we used double dots in expression. This does recursive scan for N number of levels)</p>
<div id="attachment_8960" style="width: 1214px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-extract-json-array-recursive-double-dot-jsonpath.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8960" class="size-full wp-image-8960" src="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-extract-json-array-recursive-double-dot-jsonpath.png" alt="JSON Path for recursive scan of nested array (many levels deep)" width="1204" height="788" srcset="https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-extract-json-array-recursive-double-dot-jsonpath.png 1204w, https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-extract-json-array-recursive-double-dot-jsonpath-300x196.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-extract-json-array-recursive-double-dot-jsonpath-768x503.png 768w, https://zappysys.com/blog/wp-content/uploads/2016/01/ssis-extract-json-array-recursive-double-dot-jsonpath-1024x670.png 1024w" sizes="(max-width: 1204px) 100vw, 1204px" /></a><p id="caption-attachment-8960" class="wp-caption-text">JSON Path for recursive scan of nested array (many levels deep)</p></div>
<h2>Parse Multi-Dimensional Array</h2>
<p>If you want to learn more how to parse Multi-Dimensional JSON arrays then check <a href="//zappysys.com/blog/parse-multi-dimensional-json-array-ssis/" target="_blank" rel="noopener">this article</a> full length article.</p>
<h3><strong>Sample JSON with Multi Dimensional array</strong></h3>
<pre class="crayon-plain-tag">{
  "columns" : ["Id", "FirstName", "IsActive"],
  "rows" : [ [1,"bob",true], [2,"sam",false], [3,"joe",true] ]
}</pre>
<h3><strong>Array Transformation Options for 2D array</strong></h3>
<p><a href="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/08/ssis-parse-json-array-pattern-1-select-2d-transformation.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1640" src="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/08/ssis-parse-json-array-pattern-1-select-2d-transformation.png?resize=687%2C165" sizes="(max-width: 687px) 100vw, 687px" srcset="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/08/ssis-parse-json-array-pattern-1-select-2d-transformation.png?w=687 687w, https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/08/ssis-parse-json-array-pattern-1-select-2d-transformation.png?resize=300%2C72 300w" alt="" width="687" height="165" data-attachment-id="1640" data-permalink="//zappysys.com/blog/parse-multi-dimensional-json-array-ssis/ssis-parse-json-array-pattern-1-select-2d-transformation/#main" data-orig-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/08/ssis-parse-json-array-pattern-1-select-2d-transformation.png?fit=687%2C165" data-orig-size="687,165" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="ssis-parse-json-array-pattern-1-select-2d-transformation" data-image-description="" data-medium-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/08/ssis-parse-json-array-pattern-1-select-2d-transformation.png?fit=300%2C72" data-large-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/08/ssis-parse-json-array-pattern-1-select-2d-transformation.png?fit=687%2C165" /></a></p>
<p><strong>Sample JSON with Multi Dimensional array (No columns in document)</strong></p><pre class="crayon-plain-tag">{
  "rows" : [ [1,"bob",true], [2,"sam",false], [3,"joe",true] ]
}</pre><p>
<strong>Array Transformation Options for 2D array</strong></p>
<p><img decoding="async" src="//zappysys.com/blog/wp-content/uploads/2017/08/ssis-parse-json-array-pattern-2-select-2d-transformation.png" /></p>
<h2>Performance Tips</h2>
<p>In this section we will describe how to make your things faster.</p>
<h3>Reduce number of requests to server by changing page size</h3>
<p>If you are doing <a href="//zappysys.com/blog/odata-paging-rest-api-paging-using-ssis-json-source/" target="_blank" rel="noopener">REST API paging to get full resultset </a> then make sure you adjust page size to appropriate number so total requests sent to server is reduced. Each request to server adds overhead. Most of API supports page size parameter. Refer to your API documentation how to adjust page size.</p>
<h3>Avoid multiple REST API Round trips by caching response</h3>
<p>If you extracting multiple arrays from REST API response using above technique then we recommend you to use <a href="//zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task </a>so save response to File or variable first and then use cached JSON data multiple times. This approach is not as friendly as others but it can certainly reduce your total API requests.</p>
<h3>Use GZip compression</h3>
<p>If your REST API supports GZip compression then check Enable Gzip on Advanced tab of <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">SSIS JSON Source (File, REST API Connector).</a> This will compress response in Gzip format from server and when it comes to your server it will be automatically decompressed by JSON Source connector. This seeds up thing significantly if you have lots of data to download.</p>
<h3>Uncheck include parent columns if not needed</h3>
<p>By default JSON Source connect includes parent column (Level above last property in filter) from the Filter path you specify. For Example  if you specify $.store.employees[*] and &#8220;Include parent columns&#8221; checked then It will extract all employees and then also include parent level columns for store (Tip: Parent column name start with P_ by default) . If you don&#8217;t need parent columns then uncheck from output, this reduces many steps during data extract process.</p>
<h2>Download sample package</h2>
<p><a href="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-parser-transform/JsonXmlMultiOutputDemo_ParserTransform_2012.zip">Click here to download SSIS 2012 Package</a> (Will work in SSIS 2014, 2016)</p>
<h2>Conclusion</h2>
<p>In this post you learned how to extract data from JSON array and how to make data extract fast. Download <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">SSIS JSON Source (File, REST API Connector)</a> to try everything listed above.</p>
<p>The post <a href="https://zappysys.com/blog/extract-read-multiple-arrays-from-json-data-file-rest-api-response/">Reading JSON Arrays from file / REST API</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
