json-fields

JSON.parse and JSON.stringify for certain properties of an object

npm install json-fields
3 downloads in the last week
19 downloads in the last month

json-fields

Build status

JSON.parse and JSON.stringify for certain properties of an object

install

$ npm install json-fields

example

JSON.parse some fields of an object:

var jsonfields = require('json-fields');

var obj = {
  'x-json-user':'{"name":"bob"}',
  'x-json-thing':'{"apple":"green"}',
  'normalfield':'{"a":10}'
}

var parsedobj = jsonfields.parse(obj, 'x-json');

JSON.stringify some fields of an object:

var jsonfields = require('json-fields');

var obj = {
  'x-json-user':{
    name:'bob'
  },
  'x-json-thing':{
    apple:'green'
  },
  'normalfield':'{"a":10}'
}

var stringobj = jsonfields.stringify(obj, 'x-json');

licence

MIT

npm loves you