English 中文(简体)
读json, 重复组
原标题:read json, repeating group

我试图制作一个窗口电话应用程序, 从网站读取 json 文件。 这个 json 文件有一个重复组, 我无法让程序读取所有组 。

这是json输出的一个例子:

{
    "program":{
        "title":"Carl Schmitz",
        "image_url":"http://q-music.be/sites/2009.q-music.be/files/NOA.jpg"
    },
    "noa":[
        {
            "title":"Behind Blue Eyes",
            "artist":"LIMP BIZKIT",
            "itunes_link":"http://clk.tradedoubler.com/click?p=24379&a=1256924?url=http://itunes.apple.com/be/album/behind-blue-eyes/id14915153?i=14915155&uo=4&partnerId=2003"
        },
        {
            "title":"Alone Again",
            "artist":"ALYSSA REID",
            "itunes_link":"http://clk.tradedoubler.com/click?p=24379&a=1256924?url=http://itunes.apple.com/be/album/alone-again-original-mix/id496520410?i=496520415&uo=4&partnerId=2003"
        }
    ]
}

谁能解释一下我怎么读这支Json吗?

最佳回答

您的班级结构应该像这个样子。 我用惊人的"http://json2csharp.com" rel="nofollow">json2csharp 来生成它:

然后,你应该能够直接向根目标进行分解。你没有提到你使用的是哪个序列,所以这里没有显示实际的分解。

public class Program
{
    public string title { get; set; }
    public string image_url { get; set; }
}

public class Noa
{
    public string title { get; set; }
    public string artist { get; set; }
    public string itunes_link { get; set; }
}

public class RootObject
{
    public Program program { get; set; }
    public List<Noa> noa { get; set; }
}
问题回答

暂无回答




相关问题
JQuery/MVC Search Issue

I have inherited a piece of work where the entry screen shows a summary of 20 calculated variables. E.g. Var A (250), Var B (79). Clicking on any of these links takes the user to a view with a ...

jQuery quicksearch plug-in tinkering with JSON

I ve implemented the quicksearch plugin by Rik Lomas and I love it for an application in a custom CMS I m building. I was wondering though, since I m going to have a bizillion items in the table if ...

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

PHP json_decode question

i m trying to use json_decode to combine a few json objects and then re-encode it. my json looks like: { "core": { "segment": [ { "id": 7, "...

Converting JSON data to Java object

I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson(). Below is an example of what the string ...

热门标签