Skip to main content
Windward

Connect to a JSON Data Source v15

Overview 

This article covers how to connect to a JSON data source in AutoTag using the new Connection Editor.  For more information, see the article on the new Connection Editor here.

 

What you need to establish a connection:

You will need a JSON (JavaScript Object Notation, file name ends in .json) file to establish your connection in AutoTag. The file can be hosted on a website, located on your network, or located on your local machine. The necessary JSON drives are installed when you install AutoTag. 

The Windward JSON drivers use JsonPath 2.1.0 as the query language to retrieve your data.

Connect Your Template to a JSON Data Source:

Step 1

From MS Word, Excel or PowerPoint, navigate to the AutoTag Manager tab. Once on the AutoTag Manager tab, click on the upper half of the Data Sources button. This will open the data source Connection Editor.

 

Note that if you click on the bottom half, you will get a dropdown menu which lists data sources that are already connected; this may be blank.

 

Step 2

Enter your organization's information. The information for Windward's sample JSON data sources is shown below.

1. In the Connection Editor window, in the New tab, click on JSON under Web data sources. The Details pane will change to prompt you for your data source details.

2. Enter a Nickname for your data source connection.

3. Type or paste the URL or Filepath for your data source, or browse to the location. If the file is stored remotely, and requires authentication, you will need to provide credentials in the Username and Password fields.

4. (Optional) Choose your Encoding (UTF-8, UTF-16, or US-ASCII). Default is ASCII, but in addition to the three i the dropdown, you can type in any encoding. 

5. Choose the Authentication Protocol (AllHttp, Anonymous, Basic, Digest, FileSystem, or Negotiate) and fill in the credentials in the properties field below.

6. Click Add, and then Test your connection. If all parameters and credentials are correct and a connection is made, you will receive a successful notification. Clicking Close will save your information. 

 

*The Root Directory is optional. This is the "default directory" for any Import Tag requests where the requested file does not have an absolute path. If left blank, AutoTag will use the directory where the data source file is located. If the data source is not a file it will use the directory where the template is located.

 

 

Windward Sample Template Credentials

To use Windward's sample templates, enter these credentials. 

 

Other Information

Authentication Protocol

See this article for more on the Authentication Protocols.

When you set all the properties for JSON you will get a connection string in the form: 

“Url= C:\test\FileName.json/;AccessProvider=FileSystem;Encoding=utf-8;”

 

.NET Engine code Java Engine Code
new JsonDataSourceImpl (“Url= C:\test\filename.json/;AccessProvider=FileSystem;Encoding=utf-8;” ); new JsonDataSource (“Url= C:\test\filename.json/;AccessProvider=FileSystem;Encoding=utf-8;” );

 

orderby() function:

The .orderby() function may be added to the end of any JsonPath expression. Doing so will return a sorted array.

 

For instance, using the Northwind database to order an array of Employees by their EmployeeID, you would use the query: $.Employees[*].orderby(EmployeeID, 1).

The parameter '1' is passed to indicate that the Employees are ordered in Ascending order. A parameter of '-1' would indicate Descending order.

If an object does not have the property specified by the orderby function (as in the EmployeeID above), then the objects are placed in arbitrary order at the end of the list.

Multiple calls to .orderby() in a single query are not yet supported.

limit() function:

The .limit() function simply limits the number of records returned. Note that the calling order of this, with respect to .orderby() does matter, so make sure you call the functions in the desired order.

ForEach Tags with arrays of literals:

If your JSON file has the form: { array: ["first", "second"] }, we can use a ForEach Tag to iterate through the items of 'array'.

To do this, we can create a ForEach Tag with the select value of “$.array[*]” and a variable with the name value of "varName1". You will also need to create an Out Tag with the select value of "${varName1}" to place within your beginning ForEach Tag and your End (ForEach) Tag.

Handling images:

Images that are embedded in JSON objects (in your file) can be either integer arrays (with values less than 256-bits), or base-64 encoded strings. In either case, use the Out Tag to view an image. The ‘type’ setting should set to ‘BITMAP’.

 

Helpful Links:

Link related to JsonPath origin: http://goessner.net/articles/JsonPath/

Link related to JsonPath 2.1.0 documentation and other functions supported: https://github.com/jayway/JsonPath

Link related to using the JSON AutoTag Wizard: https://wiki.windward.net/Wiki/03.AutoTag/05.AutoTag_User_Guide/03.Tagging/09.Tag_Wizards/JSON_Wizard