Serialize and deserialize String, and add length check.