Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
1
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc