<a id="sftp-json-source-connector"></a>

# JSON Source Connector for Confluent Platform

The Kafka Connect JSON Source connector is used to [stream JSON files](https://en.wikipedia.org/wiki/JSON_Streaming)  from an SFTP directory while also converting the data based on the schema supplied in the configuration. If the schema is not supplied in the configuration then the connector can also auto generate the `key.schema` and `value.schema` at run time when `schema.generation.enabled` is true.

To use this connector, use a connector configuration that specifies the name of this connector class in the `connector.class` configuration property, as shown below:

```properties
connector.class=io.confluent.connect.sftp.SftpJsonSourceConnector
```

<a id="sftp-connector-json-example"></a>

## JSON Source Connector Example

This example follows the same steps as the Quick Start. Review the [Quick Start](overview.md#sftp-source-connector-quickstart) for help running the Confluent Platform and installing the SFTP connector package.

1. Generate a JSON dataset using the command below and push it to SFTP server:
   ```bash
   echo $'{"id":1,"first_name":"Roscoe","last_name":"Brentnall","email":"rbrentnall0@mediafire.com","gender":"Male","ip_address":"202.84.142.254","last_login":"2018-02-12T06:26:23Z","account_balance":1450.68,"country":"CZ","favorite_color":"#4eaefa"}\n{"id":2,"first_name":"Gregoire","last_name":"Fentem","email":"gfentem1@nsw.gov.au","gender":"Male","ip_address":"221.159.106.63","last_login":"2015-03-27T00:29:56Z","account_balance":1392.37,"country":"ID","favorite_color":"#e8f686"}' > "json-sftp-source.json"
   ```
2. Create an `sftp.properties` file with the following contents:
   ```properties
   name=JsonSftp
   tasks.max=1
   connector.class=io.confluent.connect.sftp.SftpJsonSourceConnector
   input.path=/path/to/data
   error.path=/path/to/error
   finished.path=/path/to/finished
   cleanup.policy=NONE
   input.file.pattern=json-sftp-source.json
   behavior.on.error=IGNORE
   sftp.username=username
   sftp.password=password
   sftp.host=localhost
   sftp.port=22
   kafka.topic=sftp-json-topic
   key.schema={\"name\" : \"com.example.users.UserKey\",\"type\" : \"STRUCT\",\"isOptional\" : false,\"fieldSchemas\" : {\"id\" : {\"type\" : \"INT64\",\"isOptional\" : false}}}
   value.schema={\"name\" : \"com.example.users.User\",\"type\" : \"STRUCT\",\"isOptional\" : false,\"fieldSchemas\" : {\"id\" : {\"type\" : \"INT64\",\"isOptional\" : false},\"first_name\" : {\"type\" : \"STRING\",\"isOptional\" : true},\"last_name\" : {\"type\" : \"STRING\",\"isOptional\" : true},\"email\" : {\"type\" : \"STRING\",\"isOptional\" : true},\"gender\" : {\"type\" : \"STRING\",\"isOptional\" : true},\"ip_address\" : {\"type\" : \"STRING\",\"isOptional\" : true},\"last_login\" : {\"type\" : \"STRING\",\"isOptional\" : true},\"account_balance\" : {\"name\" : \"org.apache.kafka.connect.data.Decimal\",\"type\" : \"BYTES\",\"version\" : 1,\"parameters\" : {\"scale\" : \"2\"},\"isOptional\" : true},\"country\" : {\"type\" : \"STRING\",\"isOptional\" : true},\"favorite_color\" : {\"type\" : \"STRING\",\"isOptional\" : true}}}
   ```
3. Load the SFTP JSON Source connector.
   ```bash
   confluent local load JsonSftp --config sftp.properties
   ```

   #### IMPORTANT
   Don’t use the [Confluent CLI](https://docs.confluent.io/confluent-cli/current/index.html) in production environments.

<a id="sftp-json-source-connector-config"></a>

## Configuration Properties

For connector-specific configuration properties, see
[SFTP Source Connector Configuration Properties](license_config.md#sftp-source-connector-license-config).
