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

awesome-json2json

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome-json2json - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

6

lib/Json2json.js

@@ -99,2 +99,8 @@ "use strict";

currentKey = currentKey.replace(/\[\]$/, '');
if (/\?$/.test(currentKey)) {
currentKey = currentKey.replace(/\?$/, '');
if (result[currentKey] === undefined) {
return [];
}
}
result = currentKey === '' ? result : result[currentKey];

@@ -101,0 +107,0 @@ return result.map(function (jsonItem) {

2

package.json
{
"name": "awesome-json2json",
"version": "0.4.3",
"version": "0.5.0",
"description": "An awesome json to json mapper",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -146,2 +146,8 @@ interface IContext {

currentKey = currentKey.replace(/\[\]$/, '');
if (/\?$/.test(currentKey)) {
currentKey = currentKey.replace(/\?$/, '');
if (result[currentKey] === undefined) {
return [];
}
}
result = currentKey === '' ? result : result[currentKey];

@@ -148,0 +154,0 @@ return result.map((jsonItem) => {

@@ -515,2 +515,28 @@ const assert = require('assert');

});
it('should support optional array', () => {
assert.deepEqual(json2json(ARRAY_FOO_BAR, {
new_foo: {
$path: 'not_exist_array?[]',
new_bar: 'bar'
}
}), {
new_foo: []
});
});
// it('should have $index context in $formatting argument', () => {
// assert.deepEqual(json2json(ARRAY_FOO_BAR, {
// new_foo: {
// $path: 'foo[].bar',
// new_bar: (barValue, { $index, $root }) => {
// return barValue + '_formatted_' + $root.foo[$index].bar;
// }
// }
// }), {
// new_foo: [
// { new_bar: '1_formatted_1' },
// { new_bar: '2_formatted_2' },
// { new_bar: '3_formatted_3' }
// ]
// });
// });
});

@@ -517,0 +543,0 @@

Sorry, the diff of this file is not supported yet

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