Moved the empty string check since empty strings are valid JSON.