0.1.1 • Published 6 years ago

yodata-context v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

yodata-context NPM version Build Status Dependency Status Coverage percentage

JSON transformation toolkit, define and test transformations with a simple yet powerful and flexible JSON transformation syntax.

Installation

$ npm install --save yodata-context

Usage

const Context = require('yodata-context');
 
// define a context for transforming your data
const myContext = 
{
  // rename keys 
  name: givenName
  
  // rename, move and combine data easily
  address1: 'address.streetAddress'
  address2: 'address.streetAddress'
  city: 'address.addressLocality'
  
  // renaming also works with values
  Customer: Person
  
  // remove keys from results
  password: null
  
  // advanced syntax provides full control of transformations
  ID: {
    key: id
    val: props => `xxx${props.value.substring(3)}`
  }
 
  
}                
                   
// compiles your context into a transform engine
let context = new Context(myContext)

// take any raw json data object
const example = {
    ID: '1234'
    type: Customer
    name: Bob
    address1: 123 Main
    address2: #1,
    city: Mountain View
    password: secret  
  }

// use context.map(data:JSON) to transform the data object.
let result = context.map(example)

// result 
{
  id: 'xxx4',
  type: 'Person',
  givenName: 'Bob',
  address: {
    streetAddress: [
      '123 Main',
      '#1'
    ],
    addressLocality: 'Mountain View'
  }
}

Examples

See more examples in the examples directory

License

MIT © Dave Duran

0.1.1

6 years ago

0.1.0

6 years ago

1.7.0

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.4.0-0

7 years ago

1.3.0-0

7 years ago

1.2.0-0

7 years ago

1.1.0-0

7 years ago

1.0.0-0

7 years ago

0.0.1-0

7 years ago