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

json2typescript

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json2typescript - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

18

CHANGELOG.md

@@ -0,1 +1,13 @@

# v1.4.0 (2020-04-14)
## Bug Fixes
* Fixed compile issues when using older TypeScript versions, closes [#131](https://github.com/AppVision-GmbH/json2typescript/issues/131)
## Breaking Changes
* The older versions did not enforce developers the use of the `@JsonObject(classId)` decorator.
If you do not use the class decorator or have no parameter given, please update according to the docs.
This is now mandatory, closes [#129](https://github.com/AppVision-GmbH/json2typescript/issues/129) and [#130](https://github.com/AppVision-GmbH/json2typescript/issues/130)
# v1.3.0 (2020-04-13)

@@ -5,3 +17,3 @@

* Fixed content of `package-lock.json`, closes #125
* Fixed content of `package-lock.json`, closes [#125](https://github.com/AppVision-GmbH/json2typescript/issues/125)

@@ -14,3 +26,5 @@ ## Features

* In previous version, the serialization of plain objects failed, because instances of classes were required. As of now, the serialization of plain object may succeed if the structure matches the class structure. Thus, this is considered a soft breaking change.
* In previous version, the serialization of plain objects failed, because instances of classes were required.
As of now, the serialization of plain object may succeed if the structure matches the class structure.
Thus, this is considered a soft breaking change.

@@ -17,0 +31,0 @@ # v1.2.5 (2020-03-01)

@@ -0,0 +0,0 @@ export { JsonConvert } from "./src/json2typescript/json-convert";

{
"name": "json2typescript",
"version": "1.3.0",
"version": "1.4.0",
"description": "Provides TypeScript methods to map a JSON object to a JavaScript object on runtime",

@@ -25,3 +25,3 @@ "keywords": [

"test": "karma start karma.conf.js",
"build": "npm run test && tsc",
"build": "npm run test && tsc && npx downlevel-dts . ts3.4 && cp -r ts3.4/* . && rm -r ts3.4",
"dist": "npm run build && npm pack"

@@ -32,5 +32,13 @@ },

},
"typesVersions": {
"<3.8": {
"*": [
"ts3.4/*"
]
}
},
"dependencies": {},
"devDependencies": {
"@types/jasmine": "^3.5.10",
"downlevel-dts": "^0.4.0",
"jasmine": "3.5.0",

@@ -37,0 +45,0 @@ "karma": "^5.0.1",

33

README.md

@@ -36,17 +36,8 @@ [![npm](https://img.shields.io/npm/v/json2typescript.svg)](https://www.npmjs.com/package/json2typescript)

See the changelog in the seperate file for bug fixes, new features and breaking changes: [Changelog](CHANGELOG.md)
See the changelog in the separate file for bug fixes, new features and breaking changes: [Changelog](CHANGELOG.md)
> Tip: At version 1.2.0 we introduced one more soft breaking change.
`null` values will now be ignored when you serialize or deserialize optional values.
This means that you are now able to use `ValueCheckingMode.DISALLOW_NULL` even when your API returns null values in the JSON.
In that case, you should mark them optional.
> Tip: We earlier suggested to use the `@JsonObject(classId)` decorator, but did not enforce it.
Since v1.4.0, this is mandatory in order to make (de)serialization work properly with class inheritance.
In versions above v1.2.0 and below v1.4.0, it is possible to run into issues when not using the decorator.
> Tip: At version 1.1.0 we introduced some soft breaking change.
`undefined` is an invalid value now for serializing or deserializing.
If you are working with TypeScript, you might receive some type issues after the update to v1.1.0.
This is due to the addition of generics; they now help the compiler to detect invalid return types in the serialize and deserialize methods.
> Tip: Starting from version 1.0.6, we recommend to use unique class identifiers in the `@JsonObject` decorator.
Read below how to use the decorators properly.
---

@@ -58,3 +49,3 @@

We developed **json2typescript** for Angular and Ionic 2+. In this document, we only cover this use case.
We developed **json2typescript** for Angular 2+ and Ionic 2+. In this document, we only cover this use case.
However, you may use our package for pure TypeScript or even JavaScript applications.

@@ -257,14 +248,10 @@

> Warning: Minification removes the actual names of certain classes. This can
in certain cases cause the deserializer to not work as same class names will
overwrite the property descriptors. It is advised to explicitly ID your
objects as above.
> Warning: The class decorator uses the parameter to identify the class.
Please use a unique identifier for each class in your project, for example simply the name of the class.
> Tip: Make sure you import `JsonObject` from `json2typescript`.
#### First parameter: classIdentifier (optional)
#### First parameter: classIdentifier
The first parameter of `@JsonObject` is meant to be a unique class identifier, usually just the class name.
In many applications, developers deploy minified code which also minifies class names.
Adding a class identifier is highly recommended because it will prevent collision of class names.
The first parameter of `@JsonObject` must be a unique class identifier, usually just the class name.

@@ -491,3 +478,3 @@ ### Property decorators

`(bool) JsonConvertignoreRequiredCheck`
`(bool) JsonConvert.ignoreRequiredCheck`

@@ -494,0 +481,0 @@ Determines whether the check for required properties should be ignored, making all mapped values optional, whether or not the isOptional property mapping parameter is set.

@@ -0,0 +0,0 @@ /**

@@ -16,3 +16,3 @@ /**

*/
export declare function JsonObject(target?: string | any): any;
export declare function JsonObject(target: string | any): any;
/**

@@ -19,0 +19,0 @@ * Decorator of a class property that comes from a JSON object.

@@ -50,13 +50,10 @@ "use strict";

// Decorator was @JsonObject
// Decorator was @JsonObject()
// Decorator was @JsonObject(123)
case "function":
decorator(target);
return;
// Decorator was @JsonObject()
case "undefined":
return decorator;
// Decorator was @JsonObject(123)
default:
throw new Error("Fatal error in JsonConvert. " +
"It is mandatory to pass a string as parameter in the @JsonObject decorator.\n\n" +
"Use either @JsonObject or @JsonObject(classId) where classId is a string.\n\n");
"Use @JsonObject(classId) where classId is a string.\n\n");
}

@@ -63,0 +60,0 @@ }

@@ -16,25 +16,4 @@ /**

private _operationMode;
operationMode: number;
/**
* Determines how the JsonConvert class instance should operate.
*
* You may assign three different values:
* - OperationMode.DISABLE: json2typescript will be disabled, no type checking or mapping is done
* - OperationMode.ENABLE: json2typescript is enabled, but only errors are logged
* - OperationMode.LOGGING: json2typescript is enabled and detailed information is logged
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
get operationMode(): number;
/**
* Determines how the JsonConvert class instance should operate.
*
* You may assign three different values:
* - OperationMode.DISABLE: json2typescript will be disabled, no type checking or mapping is done
* - OperationMode.ENABLE: json2typescript is enabled, but only errors are logged
* - OperationMode.LOGGING: json2typescript is enabled and detailed information is logged
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
set operationMode(value: number);
/**
* Determines which types are allowed to be null.

@@ -48,25 +27,4 @@ *

private _valueCheckingMode;
valueCheckingMode: number;
/**
* Determines which types are allowed to be null.
*
* You may assign three different values:
* - ValueCheckingMode.ALLOW_NULL: all given values in the JSON are allowed to be null
* - ValueCheckingMode.ALLOW_OBJECT_NULL: objects in the JSON are allowed to be null, primitive types are not allowed to be null
* - ValueCheckingMode.DISALLOW_NULL: no null values are tolerated in the JSON
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
get valueCheckingMode(): number;
/**
* Determines which types are allowed to be null.
*
* You may assign three different values:
* - ValueCheckingMode.ALLOW_NULL: all given values in the JSON are allowed to be null
* - ValueCheckingMode.ALLOW_OBJECT_NULL: objects in the JSON are allowed to be null, primitive types are not allowed to be null
* - ValueCheckingMode.DISALLOW_NULL: no null values are tolerated in the JSON
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
set valueCheckingMode(value: number);
/**
* Determines whether primitive types should be checked.

@@ -76,17 +34,4 @@ * If true, it will be allowed to assign primitive to other primitive types.

private _ignorePrimitiveChecks;
ignorePrimitiveChecks: boolean;
/**
* Determines whether primitive types should be checked.
* If true, it will be allowed to assign primitive to other primitive types.
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
get ignorePrimitiveChecks(): boolean;
/**
* Determines whether primitive types should be checked.
* If true, it will be allowed to assign primitive to other primitive types.
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
set ignorePrimitiveChecks(value: boolean);
/**
* Determines the rule of how JSON properties shall be matched with class properties during deserialization.

@@ -99,23 +44,4 @@ *

private _propertyMatchingRule;
propertyMatchingRule: number;
/**
* Determines the rule of how JSON properties shall be matched with class properties during deserialization.
*
* You may assign the following values:
* - PropertyMatchingRule.CASE_STRICT: JSON properties need to match exactly the names in the decorators
* - PropertyMatchingRule.CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
get propertyMatchingRule(): number;
/**
* Determines the rule of how JSON properties shall be matched with class properties during deserialization.
*
* You may assign the following values:
* - PropertyMatchingRule.CASE_STRICT: JSON properties need to match exactly the names in the decorators
* - PropertyMatchingRule.CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
set propertyMatchingRule(value: number);
/**
* Determines whether the check for "required" properties should be ignored, making all

@@ -127,21 +53,4 @@ * mapped values optional, whether or not the isOptional property mapping parameter is set.

private _ignoreRequiredCheck;
ignoreRequiredCheck: boolean;
/**
* Determines whether the check for "required" properties should be ignored, making all
* mapped values optional, whether or not the isOptional property mapping parameter is set.
* If true, any missing properties (undefined) when serializing or deserializing will be
* ignored, as if they were marked optional.
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
get ignoreRequiredCheck(): boolean;
/**
* Determines whether the check for "required" properties should be ignored, making all
* mapped values optional, whether or not the isOptional property mapping parameter is set.
* If true, any missing properties (undefined) when serializing or deserializing will be
* ignored, as if they were marked optional.
*
* @see https://www.npmjs.com/package/json2typescript full documentation
*/
set ignoreRequiredCheck(value: boolean);
/**
* Constructor.

@@ -148,0 +57,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