GoDFT – JSON Driver

JSON as Source

Parameters-

KeyValue TypeType
inputPathPath of a json file
or
Path to a directory containing JSON files. In the case of directory, all JSON files in the directory will be parsed.
array
json-driver-config:
  driver: json
  inputPath:
    - ./path/to/a/directory/ # All json file from this directory
    - ./path/to/a/file/sample.json

JSON as Destination

KeyValue TypeType
outputPathDirectory pathstring

NOTES

  • Make sure to pass readOnly: false, to write to JSON file.
json-driver-config:
  driver: json
  input: key-of-the-input-driver
  outputPath: ./docs/testres/
  readOnly: false

Examples

# Generator to JSON

# Source service
my-generator:
  driver: generator
  collection:
    customer:
      field:
        full_name: name
        age: number:10:90
        address: address
        customerid: number
        phone: phone
        number1: number:100:200
        number2: number:100
        number3: number::200
        decimal1: decimal:20
        id: number::400
        sku: uuid
        price: decimal::99
    product:
      limit: 3
      
    order:
      limit: 5

      field:
        price: number
        product: uuid
        quantity: number:1:25

# Destination service
fake-data-json-child:
  driver: json
  input: my-generator
  readOnly: false
# JSON to MongoDB

json-parent:
  driver: json
  inputPath:
    - ./docs/testres/ # All json file from this directory
    - ./docs/customer_sample.json

my-mongo:
  driver: mongo
  connection: mongodb://webhkp:secretpass@localhost:27017/?maxPoolSize=20&w=majority
  database: godft
  readOnly: false
  input: json-parent # Receive data from "json_parent" service
# MongoDB to JSON

# Source service
my-mongo-input:
  driver: mongo
  connection: mongodb://webhkp:secretpass@localhost:27017/?maxPoolSize=20&w=majority
  database: bigboxcode
  collection:
    customer:
      limit: 4
      sort:
        age: -1
      field:
        - address.city
        - age
        - name
    product:
      limit: 10
      sort:
        id: -1
    order:
      field:
        - price
        - customer
        - quantity
      sort:
        price: 1
        quantity: -10
      limit: 22

# Destination service
json-child:
  driver: json
  input: my-mongo-input # Define the source, from which this service will get data
  outputPath: ./docs/testres/
  readOnly: false # Make this instance writable
# MySQL to JSON

mysql-source:
  driver: mysql
  host: 127.0.0.1
  port: 3306
  user: root
  password: root
  database: issue_tracker
  collection: all

json-child:
  driver: json
  input: mysql-source
  outputPath: ./docs/testres/
  readOnly: false

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.