🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

json-sub

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-sub

Substitute placeholders in json Objects.

1.1.0
Source
npm
Version published
Weekly downloads
5
-28.57%
Maintainers
1
Weekly downloads
 
Created
Source

#jsonSub Lightweight module for substitution in json object. Use {{placeholder}} (double curly braces) to define your placeholder in the json object and the variables object.

Install

npm install json-sub

Usage Example

	var jsonSub = require('json-sub')();
	
	var json = [{
		method : 'get',
		path : '/reports/{{campaign_id}}/members',
	},
	{
		method : 'get',
		path : '/city/{{store_id}}/turnover',
	}];

	var variables = {
		'{{campaign_id}}' : 'mc1234567d',
		'{{store_id}}' : 76890
	}
	
	// Substitution
	var jsonSub(json, variables, function(result) {
		console.log(result);
	});
	
	
	// OUTPUTS
	/* [
		{ method: 'get', path: '/reports/mc1234567d/members' },
		{ method: 'get', path: '/city/76890/turnover' }
	] */

Synchronous Method

	var jsonSub = require('json-sub')();
	
	// In Synchronous mode
	var result = jsonSub.SubSync(json, variables);
	

Keywords

json

FAQs

Package last updated on 31 Mar 2016

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