JSON (Windows 10 Universal C #)

Vibhav Patil
[
    {
        "img":[
            "http://inventory.vibhavpatil.com/productimages/912b4loRgiL._UL1500_.jpg",
            "http://inventory.vibhavpatil.com/productimages/fdsfdsf.jpg"
        ],
        "Colour":[
            "Grey"
        ],
        "Size":[
            "Medium"
        ],
        "productcode":"0001",
        "productname":"Alan Jones Men\u0027s Cotton Printed T-Shirt",
        "productbrand":"sousamoda",
        "productcat":"clothing",
        "productsubcat":"t-shirt",
        "productmindec":"Look stylish and impressive",
        "actualprice":"899",
        "bestprice":"419",
        "quantity":"5",
        "designer":"Adidas"
    }
]

위는 내 JSON 출력입니다.

제품 코드 등과 같은 다른 단일 출력을 얻을 수있었습니다. 그러나 "img [0]"및 "img [1]"이미지 링크를 얻는 방법에 대한 도움말을 원했습니다. 아래는 내 코드입니다.

class FullDetails
{
    public string productcode { get; set; }
    public string productname { get; set; }
    public string productbrand { get; set; }
    public string productcat { get; set; }
    public string productsubcat { get; set; }
    public string productmindec { get; set; }
    public string actualprice { get; set; }
    public string bestprice { get; set; }
    public string quantity { get; set; }
    public string designer { get; set; }      
    public List<string> img = new List<string>();
    public List<string> Colour = new List<string>();
    public List<string> Size = new List<string>();
}

내 C # 코드

Array obj = JArray.Parse(urlContents);          

for (int i = 0; i < obj.Count; i++)
{

    JObject row = JObject.Parse(obj[i].ToString());
    try
    {
        var item1 = new FullDetails();
        item1.productcode = row["productcode"].ToString();
        item1.productname = row["productname"].ToString();
        item1.productmindec = row["productmindec"].ToString();                   
        item1.actualprice = row["actualprice"].ToString();
        item1.bestprice = row["bestprice"].ToString();
        item1.productbrand = row["productbrand"].ToString();
        item1.productcat = row["productcat"].ToString();
        item1.productsubcat = row["productsubcat"].ToString();
        item1.quantity = row["quantity"].ToString();
        item1.designer = row["designer"].ToString();

        item1.img[0]= row["img"][0].ToString();                

        list1.Items.Add(item1);
    }
    catch
    {

    }
}
앤더슨 피 멘텔

JSON을 구문 분석하려는 경우 모든 항목을 개별적으로 가져올 필요가 없습니다.

JSON.Net같은 JSON 도구를 사용하고 한 줄로이 작업을 수행하십시오.

var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<FullDetails[]>(serialized);

배열에 항목이 하나만 있더라도 FullDetails[]URL이 배열을 반환하기 때문에 배열 ( )로 역 직렬화하고 있습니다 (컨텐츠는 [and 로 묶임 ]).

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Windows Mobile 10의 Windows 10 Universal Javascript 앱 SQLite

분류에서Dev

Windows 10 Universal (C #)에서 직렬 포트를 계속 읽을 수있는 방법

분류에서Dev

장치 (Windows 머신 10,8.1)에 Windows Universal App 8.1 설치

분류에서Dev

Windows Universal App 8.1 C++ / Custom Class Property

분류에서Dev

Windows 10 Universal App 페이지 간 탐색 VB.NET

분류에서Dev

사용자 지정 컨트롤 바인딩 문제 (Windows Universal 10)

분류에서Dev

Windows Universal 10 강제 다운로드 언어 리소스

분류에서Dev

Windows Phone 10 Universal, 직사각형 크기 조정 및 이동 방법

분류에서Dev

피벗 헤더 템플릿 문제 Windows Universal C # XAML

분류에서Dev

C # Windows Universal API를 Winforms로 가져 오기

분류에서Dev

Windows 10의 Blurry Dev C ++

분류에서Dev

C # Windows 업데이트 API Windows 10?

분류에서Dev

Music Library Universal Windows C #의 ListView를 만드는 방법은 무엇입니까?

분류에서Dev

플로팅 / 차트를위한 Universal Windows 10 앱의 툴킷 / 확장 프로그램을 찾고 있습니다.

분류에서Dev

Windows Universal App 10에서 PUSH NOTIFICATION을 구현하는 방법은 무엇입니까?

분류에서Dev

WebRequest에 Windows 10 Universal App의 'GetResponse'에 대한 정의가 포함되어 있지 않습니다.

분류에서Dev

Windows Universal App 10의 PageResource에서 DataTemplate을 ContentControl로 설정하려면 어떻게해야합니까?

분류에서Dev

Sync data between devices with windows universal app

분류에서Dev

Changing Windows Universal App LockScreen Background

분류에서Dev

Interactive MapIcon, Windows Phone 8.1 Universal App

분류에서Dev

C # Universal WIndows 앱에서 시간 제한 StreamSocket으로 취소하는 방법은 무엇입니까?

분류에서Dev

Keep Windows 10 reserve even in Windows 10?

분류에서Dev

Windows 10 Universal Application-순수 JavaScript를 사용하여 응용 프로그램에서 파일의 압축을 풀 수 있습니까?

분류에서Dev

Windows Phone Universal App error calling async function on load

분류에서Dev

Windows Phone 8.1 Universal app adding a new contact

분류에서Dev

Windows Universal Apps의 애니메이션

분류에서Dev

Windows Universal에서 CultureInfo 간의 불일치

분류에서Dev

Windows Universal Collection에서 DesignData 사용

분류에서Dev

Windows 10 IOT Core, 일반 C ++ dll 및 C # 코드 지원?

Related 관련 기사

  1. 1

    Windows Mobile 10의 Windows 10 Universal Javascript 앱 SQLite

  2. 2

    Windows 10 Universal (C #)에서 직렬 포트를 계속 읽을 수있는 방법

  3. 3

    장치 (Windows 머신 10,8.1)에 Windows Universal App 8.1 설치

  4. 4

    Windows Universal App 8.1 C++ / Custom Class Property

  5. 5

    Windows 10 Universal App 페이지 간 탐색 VB.NET

  6. 6

    사용자 지정 컨트롤 바인딩 문제 (Windows Universal 10)

  7. 7

    Windows Universal 10 강제 다운로드 언어 리소스

  8. 8

    Windows Phone 10 Universal, 직사각형 크기 조정 및 이동 방법

  9. 9

    피벗 헤더 템플릿 문제 Windows Universal C # XAML

  10. 10

    C # Windows Universal API를 Winforms로 가져 오기

  11. 11

    Windows 10의 Blurry Dev C ++

  12. 12

    C # Windows 업데이트 API Windows 10?

  13. 13

    Music Library Universal Windows C #의 ListView를 만드는 방법은 무엇입니까?

  14. 14

    플로팅 / 차트를위한 Universal Windows 10 앱의 툴킷 / 확장 프로그램을 찾고 있습니다.

  15. 15

    Windows Universal App 10에서 PUSH NOTIFICATION을 구현하는 방법은 무엇입니까?

  16. 16

    WebRequest에 Windows 10 Universal App의 'GetResponse'에 대한 정의가 포함되어 있지 않습니다.

  17. 17

    Windows Universal App 10의 PageResource에서 DataTemplate을 ContentControl로 설정하려면 어떻게해야합니까?

  18. 18

    Sync data between devices with windows universal app

  19. 19

    Changing Windows Universal App LockScreen Background

  20. 20

    Interactive MapIcon, Windows Phone 8.1 Universal App

  21. 21

    C # Universal WIndows 앱에서 시간 제한 StreamSocket으로 취소하는 방법은 무엇입니까?

  22. 22

    Keep Windows 10 reserve even in Windows 10?

  23. 23

    Windows 10 Universal Application-순수 JavaScript를 사용하여 응용 프로그램에서 파일의 압축을 풀 수 있습니까?

  24. 24

    Windows Phone Universal App error calling async function on load

  25. 25

    Windows Phone 8.1 Universal app adding a new contact

  26. 26

    Windows Universal Apps의 애니메이션

  27. 27

    Windows Universal에서 CultureInfo 간의 불일치

  28. 28

    Windows Universal Collection에서 DesignData 사용

  29. 29

    Windows 10 IOT Core, 일반 C ++ dll 및 C # 코드 지원?

뜨겁다태그

보관