0.2.11 • Published 2 months ago

@aux4/adapter v0.2.11

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

@aux4/adapter

Install

$ npm install --global @aux4/adapter

Usage

config.yml

config:
  my-mapping:
    transformers:
      GENDER:
        type: replace
        replace:
          M: MALE
          F: FEMALE
      DATE:
        type: date
        format: MM/DD/YYYY
    
    root:
      path: $.data
    mapping:
      name: $.name
      age: $.age
      birthdate:
        path: $.birthdate
        transformer: DATE
      gender:
        path: $.gender
        transformer: GENDER
      place:
        type: object
        mapping:
          city: $.address.city

test.json

{
  "data": [
    {
      "name": "John",
      "age": 31,
      "birthdate": "1992-04-10",
      "gender": "M",
      "address": {
        "city": "New York"
      }
    },
    {
      "name": "Mary",
      "age": 27,
      "birthdate": "1996-02-14",
      "gender": "F",
      "address": {
        "city": "Boston"
      }
    }
  ]
}
$ cat test.json | adapter map --config my-mapping --format json
[
  {
    "name": "John",
    "age": 31,
    "birthdate": "04/10/1992",
    "gender": "MALE",
    "place": {
      "city": "New York"
    }
  },
  {
    "name": "Mary",
    "age": 27,
    "birthdate": "02/14/1996",
    "gender": "FEMALE",
    "place": {
      "city": "Boston"
    }
  }
]
0.2.11

2 months ago

0.2.10

3 months ago

0.2.7

8 months ago

0.2.6

8 months ago

0.2.9

7 months ago

0.2.8

8 months ago

0.2.3

9 months ago

0.2.5

9 months ago

0.2.4

9 months ago

0.2.1

11 months ago

0.2.2

11 months ago

0.1.5

12 months ago

0.1.1

12 months ago