New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

json-string-merge

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-string-merge

Merge two JSON strings while keeping both properties.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

json-string-merge

Merge two JSON strings while keeping both properties. The value of the property with the same name will be overwritten.

Usage

Install

npm install json-string-merge

Example

const mergeJson = require('json-string-merge');

const jsonA = `{"foo":"myValue","bar":{"barKey1":"myValue1","barKey2":"myValue2"},
"myArray":[{"arrKey1":"arrValue1"},{"arrKey2":"arrValue2"}]}`;

const jsonB = `{"foo":"updatedMyValue","bar":{"barKey1":"updatedMyValue1","barKey2":"myValue2"},
"some":{"someKey":"someValue"},
"myArray":[{"arrKey3":"arrValue3"},{"arrKey4":"arrValue4"}]}`;

const jsonResult =mergeJson(jsonA,jsonB);

console.log('jsonResult=');
console.log(jsonResult);


When you run it you will get the following result.

jsonResult=
{"foo":"updatedMyValue","bar":{"barKey1":"updatedMyValue1","barKey2":"myValue2"},"myArray":[{"arrKey1":"arrValue1"},{"arrKey2":"arrValue2"},{"arrKey3":"arrValue3"},{"arrKey4":"arrValue4"}],"some":{"someKey":"someValue"}}

FAQs

Package last updated on 28 Jan 2020

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