handle elements that appear optionally in the JSON input

If an element does not appear an NPE is thrown and handled by the catch in method deserialize. This causes a problem if the optional element appears in a nested element e.g. inside a struct. The whole nested element is replaced by NULL.