New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1.1 to 0.1.2

5

lib/index.d.ts

@@ -1,2 +0,3 @@

import { TypeTemplate } from './Json2json';
export default function json2json(json: any, template: TypeTemplate): any;
import { Template } from './Json2json';
export default function json2json<T>(json: any, template: Template<T>): T;
export { Template };

12

lib/Json2json.d.ts

@@ -1,8 +0,8 @@

export declare type TypeTemplate = IFullTemplate | string | Function;
export interface IFullTemplate {
export declare type Template<T> = IFullTemplate<T> | string | Function;
export interface IFullTemplate<T> {
$path?: string;
$formatting?: Function;
[propName: string]: TypeTemplate;
[propName: string]: Template<T>;
}
export default class Json2json {
export default class Json2json<T> {
private static PATH_SEPARATOR;

@@ -12,4 +12,4 @@ private static PATH_ROOT;

private root;
constructor(template: TypeTemplate);
map(json: any): any;
constructor(template: Template<T>);
map(json: any): T;
private mapChild(json, template);

@@ -16,0 +16,0 @@ private getFullTemplate(template);

{
"name": "awesome-json2json",
"version": "0.1.1",
"version": "0.1.2",
"description": "An awesome json to json mapper",

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

@@ -5,3 +5,3 @@ # Awesome json2json

An awesome json to jsone mapper
An awesome json to json mapper

@@ -8,0 +8,0 @@ ## Installation

@@ -1,6 +0,10 @@

import Json2json, { TypeTemplate } from './Json2json';
import Json2json, { Template } from './Json2json';
export default function json2json(json: any, template: TypeTemplate) {
export default function json2json<T>(json: any, template: Template<T>) {
const mapper = new Json2json(template);
return mapper.map(json);
}
}
export {
Template
}

@@ -1,15 +0,15 @@

export type TypeTemplate = IFullTemplate | string | Function;
export type Template<T> = IFullTemplate<T> | string | Function;
export interface IFullTemplate {
export interface IFullTemplate<T> {
$path?: string;
$formatting?: Function;
[propName: string]: TypeTemplate;
[propName: string]: Template<T>;
}
export default class Json2json {
export default class Json2json<T> {
private static PATH_SEPARATOR = '.';
private static PATH_ROOT = '$root';
private template: TypeTemplate;
private template: Template<T>;
private root: any;
constructor(template: TypeTemplate) {
constructor(template: Template<T>) {
this.template = template;

@@ -22,3 +22,3 @@ }

}
private mapChild(json: any, template: TypeTemplate) {
private mapChild(json: any, template: Template<T>): T {
const fullTemplate = this.getFullTemplate(template);

@@ -54,6 +54,6 @@ let currentJSON = json;

});
return result;
return (result as T);
}
private getFullTemplate(template: TypeTemplate) {
let fullTemplate: IFullTemplate = {
private getFullTemplate(template: Template<T>) {
let fullTemplate: IFullTemplate<T> = {
$path: '',

@@ -60,0 +60,0 @@ $formatting: null

Sorry, the diff of this file is not supported yet

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