Fixes Issue #1581; caused by assumption that type is null.
Merge branch 'bug-1581-jsonTypeNPE'