Skip to content

Commit 9eda9af

Browse files
committed
Getting ready for release
1 parent f11581d commit 9eda9af

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ Lets have a look at an example:
4343
```typescript
4444
class SimpleRoster {
4545
@JsonProperty()
46-
private name: String;
46+
private name: String = undefined;
4747
@JsonProperty()
48-
private worksOnWeekend: Boolean;
48+
private worksOnWeekend: Boolean = undefined;
4949
@JsonProperty()
50-
private numberOfHours: Number;
50+
private numberOfHours: Number = undefined;
5151
@JsonProperty({type:Date})
5252
private systemDate: Date;
5353

@@ -140,7 +140,33 @@ and make sure to import it in a global place, like app.ts:
140140
import "reflect-metadata";
141141
```
142142
If you are using Angular 2 you should already have this shim installed.
143+
143144
## Things to remember
145+
146+
### Ignoring `name` metadata during de-serialization
147+
If you have an use case where you want to not use `name` metadata using de-serialization, the you cna turn if off by setting `ignoreNameMetadata` to true (default is false). Here is an example usage:
148+
149+
```typescript
150+
class Event {
151+
@JsonProperty()
152+
id: number = undefined;
153+
@JsonProperty({ name: "geo-location" })
154+
location = "old";
155+
}
156+
157+
const json = {
158+
id: "1",
159+
location: "Canberra",
160+
};
161+
162+
const testInstance: Event = ObjectMapper.deserialize(Event, json, {ignoreNameMetadata: true});
163+
expect(testInstance.location).toBe("Canberra");
164+
165+
const serialized = ObjectMapper.serialize(testInstance);
166+
aexpect(serialized).toBe('{"id":"1","geo-location":"Canberra"}');
167+
168+
```
169+
144170
### Enum serialization and de-serialization
145171
You can use `enum` data type by specifying the `type` property of @JsonProperty decorator.
146172
You will need to use `Serializer` and `Deserializer` to make the enum work correctly.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-object-mapper",
3-
"version": "1.7.2",
3+
"version": "1.8.0",
44
"description": "A TypeScript library to serialize and deserialize JSON objects in a fast and non-recursive way",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)