# Import JSON files - advanced settings

Import JSON files using some advanced settings in Productsup.

## What is a JSON file?

JSON is a versatile file format, which is often used to describe complex data with relationships and inheritance. Every product in a JSON file contains attribute keys and attribute values. One key directly relates to one value. In the below example, id is the key, and 123 is the key value.

{"id":"123"}

Every product in a JSON opens and closes with a curly bracket.

Here is an example of a typical JSON file:

[
{
"id":"123",
"title": "Red Shirt",
"size": "Large",
"price": "30 EUR",
"stock": "5"
},
{
"id":"456",
"title": "Blue Shirt",
"size": "Small",
"price": "25 EUR",
"stock": "5"
}
]

You can import your raw JSON files via URL or through other options, such as via API or apps.

As JSON files can be very versatile, the Platform first needs to understand them, which it does by parsing them. To make sure the data is parsed correctly in the way you expect it, you can specify JSON settings in the data source setup.

## What to do if your JSON file has a root node

Occasionally, a JSON file may have a root node, which defines the key under which your product data falls.

[{
"items": [
{
"id": "123",
"title": "Red Shirt",
"size": "Large",
"price": "30 EUR",
"stock": "5"
},
{
"id":"456",
"title": "Blue Shirt",
"size": "Small",
"price": "25 EUR",
"stock": "5"
}
]
}]

In the above example, our root node would be items.

You can define the root node in the platform. To add in this setting, navigate to content options and JSON settings under the advanced settings of your data source. You can then add in the root node.

## What to do with variants in your JSON file

You may have product variants in your JSON file and want to import them all.

[{
"items": [
{
"id": "123",
"title": "Red Shirt",
"price": "30 EUR",
"variant": [
{
"size": "Large",
"stock": "5"
},
{
"size": "Small",
"stock": "2"
}
]
}
]
}]

In the above example, we have two size variants of the same red shirt. These are under the items root node, which you should also declare in the Platform. We should input the variant node, so the Platform knows how to parse this file correctly. For the above example, the variant node would be variant.

You can define the variants in the platform. To add in this setting, navigate to content options and JSON settings under the advanced settings of your data source. You can then add in the variant node.

## Bundle repeating variant keys

Sometimes you may have key repeated in a JSON file. As a default, a new column will be created for each key.

[
{
"id": "123",
"title": "Red Shirt",
"size": "Small"
}
]

Standard Platform behavior would therefore create the following import data:

id

title

size_1

size_2

size_3

123

Red Shirt

Large

Medium

Small

If we choose, we can bundle the duplicated size columns using : as a delimiter, to create:

id

title

size

123

Red Shirt

Large:Medium:Small

To add in this setting, navigate to content options and JSON settings under the advanced settings of your data source. Tick the bundle box and define your bundle delimiter.

## Exclude specific keys

You may wish to exclude specific keys from the import.

[
{
"id": "123",
"title": "Red Shirt",
"size": "Large",
"publishDate": "19-05-2020"
}
]

If you don’t need the publishDate key, you can exclude it in order to get the following import data:

id

title

size

123

Red Shirt

Large

In order to do so, navigate to content options and JSON settings under the advanced settings of your data source. Enter the key you wish to exclude into the exclude items box.

### Tip

You can add more than one item to exclude, simply enter them comma-separated into the exclude items field.

## Transform a JSON file to a CSV file in the platform

Although the Feed URL data source can import JSON files as standard, you may wish to transform your JSON files into CSV files before importing them.

You can do this for JSON files you import via the Feed URL or local upload data source.

To do so:

2. Navigate to Data Sources

3. Click on the settings wheel of your Feed URL or local upload data source

4. Click on the advanced settings tab

5. Click on I/O Settings

6. Add the transform JSON to CSV option found under the available I/O settings section

7. Enter the root node under the product path

8. Enter the multiline delimiter (if necessary)

9. Click Save