Contents

Develop
2013.04.23 17:35

[c#] Hashtable <-> Json (dll 포함)

Views 80731 Comment 0
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
# 샘플코드
using System.Net.Json;

public string ConvertHashtableToJson(Hashtable data)
{
    JsonObjectCollection result = new JsonObjectCollection();

    foreach(DictionaryEntry item in data)
    {
        result.Add(new JsonStringValue(item.Key.ToString(),
            item.Value.ToString()));
    } 

    return result.ToString();
}

public Hashtable ConvertJsonToHashtable(string json)
{
    JsonTextParser parse = new JsonTextParser();
    JsonObject object = parse.Parse(json);
    Hashtable result = new Hashtable();

    foreach(JsonObject item in obj as JsonObjectCollection)
    {
        result.add(item.Name, item.GetValue().ToString());
    }
}

[참고] http://bit.ly/hYMCLL (여기와 같은 dll을 업로드 함.)
TAG •

?

List of Articles
No. Category Subject Author Date Views
13 Develop [android] Calling activity function from separate class hooni 2016.11.15 1316
12 Develop [android] How can I place app icon on launcher home screen? hooni 2016.11.15 1417
11 Develop [ios] FlckrFeed Example App (Swift) file hooni 2016.11.27 1213
10 Develop XML, JSON, BSON, MSGPACK 장,단점 비교 file hooni 2017.01.11 2385
9 Develop [ios] 동영상 플레이어 샘플 (for Local File) file hooni 2017.02.07 1213
8 Develop [ios] 동영상 플레이어 샘플 (for Remote Url) file hooni 2017.02.07 1769
7 Develop [ios] Facebook Cache 갱신하는 함수 file hooni 2017.02.27 1330
6 Develop [ios] 동영상 플레이어 샘플 (for PIP Player) file hooni 2017.03.15 1410
5 Develop Mac OS 에 Jenkins 설치하기 (Homebrew) 2 file hooni 2017.03.15 8409
4 Develop [ios] Xcode에서 특정 파일만 ARC 따로 설정하는 방법 file hooni 2017.03.29 1096
3 Develop [ios] NSString, RegularExpression Find/Replace hooni 2017.04.14 962
2 Develop [ios] Facebook SDK 로그인 설명 file hooni 2017.04.19 1363
Board Pagination Prev 1 2 3 4 5 6 Next
/ 6