json-object-mapper icon indicating copy to clipboard operation
json-object-mapper copied to clipboard

Deserialization not working on typescript 3.1.1

Open jonghshin opened this issue 5 years ago • 2 comments

Hello,

Deserialization does not work on typescript 3.1.1 and/or Angular 10. I copied, pasted and ran the SimpleRoster deserialization example on typescript 3.1.1 and/or Angular 10, but that example does not work. I created stackblitz.

https://stackblitz.com/edit/angular-ivy-ftq9ct?file=src%2Fapp%2Fapp.component.ts

jonghshin avatar Sep 22 '20 14:09 jonghshin

I just found out that only the properties that have initial values are being deserialized. It looks like line 243 in ObjectMapper.js is the problem. Object.keys only returns properties that have values.

jonghshin avatar Sep 22 '20 15:09 jonghshin

Hi Jonghshin,

as describe in the README, you should initialize your properties to undefined. It fixes the deserialization. Your stackblitz with the fix https://stackblitz.com/edit/angular-ivy-pknkua?file=src%2Fapp%2Fapp.component.ts

nicko466 avatar May 26 '21 12:05 nicko466