Ensured data is valid JSON

Also changed empty strings to nulls.