Only serialize metadata if there's something there