1.excel 파일->json파일로 만들기
2.컨버트: https://shancarter.github.io/mr-data-converter/
3.NewtonSoft.Json 추가
4.바인딩(맵핑)클래스 만들기(~~~data.cs)
5.json문자열->객체(역직렬화)
6.dictionary 에 옮겨담기
7. App class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
namespace Study_013_2
{
class App
{
public App()
{
string json = File.ReadAllText(path);
CharacterData[] arrCharacterDatas= JsonConvert.DeserializeObject<CharacterData[]>(json);
//foreach(CharacterData testData in arrCharacterDatas)
//{
// Console.WriteLine("{0}, {1}, {2}", testData.id,testData.name, testData.grade);
//}
Dictionary<int, CharacterData> dicCharacterDatas = new Dictionary<int, CharacterData>();
foreach(CharacterData data in arrCharacterDatas)
{
}
foreach(KeyValuePair<int, CharacterData> pair in dicCharacterDatas)
{
}
}
}
}
|
8. CharacterData class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_013_2
{
class CharacterData
{
public int id;
public string name;
public int grade;
}
}
|
9. 결과값
'C# > 수업내용' 카테고리의 다른 글
2020.04.23. 수업내용 - json 파일 읽고 쓰기(불러오기, 저장하기) 2 (0) | 2020.04.23 |
---|---|
2020.04.22. 수업내용 - json 파일 읽고 쓰기(불러오기, 저장하기) (0) | 2020.04.22 |
2020.04.21. 수업내용 - Dictionary 개요 (0) | 2020.04.21 |
2020.04.20. 수업내용 - 아이템 수량만 늘리기(객체 생성 x) (0) | 2020.04.21 |
2020.04.20. 수업내용 - data 클래스 따로 만들기 (0) | 2020.04.21 |