2014-10-14 1 views
0

this 솔루션을 사용하여 JSON 문자열을 비 직렬화했습니다. 가능하다면 제 3 자 라이브러리를 피하려고합니다.값이 JSON 문자열로 된 JSON 탈색

그러나, 나는 함께 일하고 있어요 JSON의 문자열과 같이 구성되어있다 :

{"BatchId":"32","BatchPriority":"NORMAL","Entries":{"Entry": 
    [{"EntryId":"185","EntryPriority":"HIGH","Value":"0.0"}, 
    {"EntryId":"172","EntryPriority":"LOW","Value":"122.0"}] 
}} 

나는 (아래 참조) Batch 객체에 BatchIdBatchPriority을 설정하는 내 JSON을 deseralize 수 있어요. 그러나 JSON 문자열 자체가 나타나는 값을 가진 JSON에서 "Entries"배열을 설정할 수 없습니다.

어떻게 내가이 BatchIdBatchPriority 속성 값을 설정할 수 있어요 단지 Batch 개체에 "항목"의 배열을 deseralize 설정할 수 있어요 있도록 내 객체 구조 않는

? 나는 public Array Entries { get; set; }을 잘못 알고 있지만 어떻게 접근해야할지 모르겠다.


Batch 목적 :

public class Batch 
{ 
    public int BatchId { get; set; } 

    public string BatchPriority { get; set; } 

    public Array Entries { get; set; } //wrong 
} 

Entry 객체 : 당신은 t 경우 List<Entry>

public class Entries 
{ 
    public List<Entry> Entry { get; set; } 
} 

을 보유하고 클래스를 만들 수

public class Entry 
{ 
    public int EntryId { get; set; } 

    public string EntryPriority { get; set; } 

    public double Value { get; set; } 
} 

답변

0

속성 public Array Entries { get; set; }System.Array이고 항목은 Entry라고하는 항목 클래스의 배열 또는 컬렉션을 원합니다.

public class Batch 
{ 
    public int BatchId { get; set; } 

    public string BatchPriority { get; set; } 

    public Entry[] Entry { get; set; } 
}