Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-sharp

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-sharp

Process operations on pure JSON objects

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

json-sharp

Process operations on pure JSON objects.

How it works

JSONSharp.process clones an object and processes operations returning a modified object.

Operations are simple objects with a single property representing its name.

The operation name should be preceded by the # (sharp) symbol to avoid conflicts with real data.

The property value is processed by the operation logic using a given context.

Motivation

Some systems need slightly different configuration between environments and contexts. This technique allows to have a good degree of reuse with a simple format.

Example

Given the following object and context:

var config = {
    '#merge': [
        {debug: true, url: 'http://localhost'},
        {
            '#switch': {
                '#property': 'env',
                '#case': {
                    dev: {
                        url: 'http://dev.com/'
                    },
                    prod: {
                        url: 'http://prod.com/',
                        debug: false
                    }
                }
            }
        }
    ]
};

var context = {
    env: 'dev'
};

var devConfig = require('JSONSharp').process(config, context);

Results in the following devConfig object:

{
    debug: true, // Debug flag inherited from merging with the defaults
    url: 'http://dev.com/' // Url is replaced
}

FAQs

Package last updated on 08 Oct 2015

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