Fix toJson method on null attributes

When the model has some attribute set to null, the exception was
raised "cannot access property toJson of null." This piece of code
fixes the issue.
Merge pull request #17 from hleumas/patch-1

Fix toJson method on null attributes