1.0.0 • Published 8 years ago

json-add-property v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

json-add-property

This module allows you to add a property to a json at a specific position. You can add a new property before or after a existing property.

let addBefore = require('json-add-property').addBefore;
let addAfter = require('json-add-property').addAfter;

let json = {
  'property1': 1,
  'property2': 2,
  'property3': 3,
  'property4': 4
};

json = addBefore(json, 'property3', 'property_before_3', 11);
json = addAfter(json, 'property3', 'property_after_3', 22);

console.log(json);
//{
//  "property1": 1,
//  "property2": 2,
//  "property_before_3": 11,
//  "property3": 3,
//  "property_after_3": 22,
//  "property4": 4
//}

License

MIT

1.0.0

8 years ago