コード例 #1
0
        protected static void ExportCsvToJsonInFileInConsoleDataDirectory(IAddressService addressService)
        {
            var csvRecords = CsvFileReader.Read(CsvFilePathImport);

            CustomValidator.ValidateJsonCsvAddressesReaderDtos(csvRecords);

            var addressBookDtos = MappingProfile.FromCsvAddressesToAddressBookDto(csvRecords);

            var jsonRecords = JsonSerializer.Serialize(addressBookDtos, _jsonSerializerOptions);

            File.WriteAllText(JsonFilePathExport, jsonRecords);

            ClearScreenAfterInteraction("Exported cvs to json file directory located @consoledata/export-addresses.json on. Press any key to clear screen and use other options...");
        }