Breadcrumbs

Export Sql query result to json

Activity

exportToJson

Description

Extract data from a DbStore into a JSONfile

Input :

PropertyName

Rule of use (if revelant)

Type

Required

Default Value

Description

connectionName


STRING

YES


name of the source connection (see DbStore)

QueryFileToken

If QueryFileToken is filled in, the content of the file specified will be used instead of Query

STRING

YES



Filetoken containing the query to execute

Query

STRING


SQL Query to execute

Params


PARAMETERS ARRAY

NO


Query parameters

CommandTimeout


INT

NO


Execution timeout of the SQL query in the database

JsonColumnNames


STRING ARRAY

NO


Name of the columns containing JSON content (these columns need to be identified to include the content in the output in JSONformat)

OutputFileStoreName


STRING

YES


Output fileStore name

OutputFileName


STRING

YES


Name of the output file (.JSONextension will be added automatically)

ExportMode

Either “SingleArray” or “FilesPerRow”

STRING

NO

SingleArray

Decide either to export one json file containing an array of objects (SingleArray) or to export one json file per row returned by the query containing only a single json Object (FilesPerRow)

FileNameColumn

Only when the mode FilesPerRow is used

STRING

YES (when using FilesPerRow)


When exporting every row as a different JSON object in a separate file, this is the name of the column that specifies the file name to export to.


Parameters

PropertyName

Type

Required

Default Value

Description

Name

STRING

YES


name of the parameter

Value

STRING

NO


value of the parameter

Output

JSONfile token

Example1: Export a query into Json

Input

{
   "connectionName": "dbStore1",
   "query":"SELECT name, role, acl FROM employees WHERE name = 'Bob'",
   "jsonColumnNames": ["acl"]
   "outputFileStoreName": "ftp1",
   "outputFileName": "employees"
}

Output

ftp://ftp1/employees.json

File content

[
   {
      "name": "bob",
      "role": "sales",
      "acl": {
          "id":1412,
          "name":"aclname"
      }
   },
   {
      "name": "bob",
      "role": "operations",
      "acl": {
          "id":4557,
          "name":"aclname"
      }
   }
]