C# This is a question about JArray.

Asked 2 years ago, Updated 2 years ago, 43 views



[   
    {
        "A" : "1",
        "B" : "2",
        "C" : "3",
        "D" : "4",
        "E" : "5",
        "F" : "6"

    },
    {
        "A" : "1",
        "B" : "2",
        "C" : "3",
        "D" : "4",
        "E" : "5",
        "F" : "6"
    }

]

I'd like to parse JSON as above.

 private void ParseJson(String json)
        {
         //   //   JObject obj = JObject.Parse(json);
            JArray array =JArray.Parse(json);

            foreach (JObject itemObj in array.Children<JObject>())
            { 
                    JsonData DownLoadData = new JsonData();
                    DownLoadData.A = itemObj["A"].ToString();
                    DownLoadData.B = itemObj["B"].ToString();
                    DownLoadData.C = itemObj["C"].ToString();
                    DownLoadData.D = itemObj["D"].ToString();

                    JsonDatas.Add(DownLoadData);

            }

        }

There is an error when coding to . Is there a way?

c#

2022-09-21 20:48

1 Answers

The data is wrong, so the parsing is wrong. The content of the sauce is correct.


2022-09-21 20:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.