🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

json-modifier

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-modifier

translate json to a specific format with a simple schema

1.2.0
latest
Source
npm
Version published
Weekly downloads
3
-78.57%
Maintainers
1
Weekly downloads
 
Created
Source

JSON Modifier

Build Status

Transform any JSON easily, provide a schema with new keys and type format to output a new format object

Install

npm install json-modifier

Usage

var JsonModifier = require('json-modifier');

var exampleObject = {
  "Name": "Filipe M. Silva",
  "Age": "28",
  "Address": {
    "house-Number": "52",
    "Street": "Lemon",
    "State": "SP"
  }
};

var addressSchema = {
  "house-Number": "houseNumber:number",
  "Street": "street:string",
  "State": "state:string"
};

var schema = {
  "Name": "name:string",
  "Age": "omit",
  "Residencial-Address": "omit",
  "Address": addressSchema
}

var translatedObject = JsonModifier(schema, exampleObject);
console.log(translatedObject);
{
  "name": "Filipe M. Silva",
  "Address": {
    "houseNumber": 52,
    "street": "Lemon",
    "state": "SP"
  }
}

Schema instructions

Schema are a json which are formated by key/rule some examples: key: newKey:type

key: Original key for modification;

newKey: new key after modification;

type: data type supported are string, number and boolean;

Attentions points for type modification

string: null and undefined values are modified to empty strings

number: undefined and non-numeric values will be transformed in NaN, and null values will be convert to 0

boolean: same behavior as transform any data in javascript

ROADMAP

  • add default values support in schema

Keywords

json

FAQs

Package last updated on 16 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts