在asp.net中反序列化Json数据

发布于 2024-12-25 10:54:42 字数 2213 浏览 1 评论 0原文

我有一些 json 数据,我想将其转换为纯文本,下面是我在 JSON 中获取的内容

{"items":[{"id":1371503932001,"name":"shure_ksm_mics","adKeys":null,"shortDescription":"shure_ksm_mics","longDescription":null,"creationDate":"1325934831982","publishedDate":"1325934831982","lastModifiedDate":"1325937858839","linkURL":null,"linkText":null,"tags":[],"videoStillURL":null,"thumbnailURL":null,"referenceId":null,"length":204130,"economics":"AD_SUPPORTED","playsTotal":null,"playsTrailingWeek":null,"FLVURL":"rtmp:\/\/brightcove.fcod.llnwd.net\/a500\/d19\/&media\/13421268001\/13421268001_1371835938001_shure-ksm-mics&1325955600000&1818a465ec2632081e214f18376d6a4d","renditions":[],"FLVFullLength":{"audioOnly":false,"controllerType":"DEFAULT","displayName":"shure_ksm_mics.flv","encodingRate":1000000,"frameHeight":480,"frameWidth":640,"id":1371835938001,"referenceId":null,"remoteStreamName":null,"remoteUrl":null,"size":29068243,"uploadTimestampMillis":1325934831973,"url":"rtmp:\/\/brightcove.fcod.llnwd.net\/a500\/d19\/&media\/13421268001\/13421268001_1371835938001_shure-ksm-mics&1325955600000&1818a465ec2632081e214f18376d6a4d","videoCodec":"ON2","videoContainer":"FLV","videoDuration":204130},"videoFullLength":{"audioOnly":false,"controllerType":"DEFAULT","displayName":"shure_ksm_mics.flv","encodingRate":1000000,"frameHeight":480,"frameWidth":640,"id":1371835938001,"referenceId":null,"remoteStreamName":null,"remoteUrl":null,"size":29068243,"uploadTimestampMillis":1325934831973,"url":"rtmp:\/\/brightcove.fcod.llnwd.net\/a500\/d19\/&media\/13421268001\/13421268001_1371835938001_shure-ksm-mics&1325955600000&1818a465ec2632081e214f18376d6a4d","videoCodec":"ON2","videoContainer":"FLV","videoDuration":204130}}],"page_number":0,"page_size":100,"total_count":-1}

我已经创建了下面的类,

public class VideoList
{
    public VideoList() { }
    private string _name;
    public string Name
    {
        get
        {
            return _name;
        }
        set 
        {
            value = _name;
        }
    }
}

目前我只想获取名称。 如何使用 System.Web.Script.Serialization.JavacriptSerializer 类来做到这一点。

i have some json data, and i want to convert it into plain text, below is the content i am getting in JSON

{"items":[{"id":1371503932001,"name":"shure_ksm_mics","adKeys":null,"shortDescription":"shure_ksm_mics","longDescription":null,"creationDate":"1325934831982","publishedDate":"1325934831982","lastModifiedDate":"1325937858839","linkURL":null,"linkText":null,"tags":[],"videoStillURL":null,"thumbnailURL":null,"referenceId":null,"length":204130,"economics":"AD_SUPPORTED","playsTotal":null,"playsTrailingWeek":null,"FLVURL":"rtmp:\/\/brightcove.fcod.llnwd.net\/a500\/d19\/&media\/13421268001\/13421268001_1371835938001_shure-ksm-mics&1325955600000&1818a465ec2632081e214f18376d6a4d","renditions":[],"FLVFullLength":{"audioOnly":false,"controllerType":"DEFAULT","displayName":"shure_ksm_mics.flv","encodingRate":1000000,"frameHeight":480,"frameWidth":640,"id":1371835938001,"referenceId":null,"remoteStreamName":null,"remoteUrl":null,"size":29068243,"uploadTimestampMillis":1325934831973,"url":"rtmp:\/\/brightcove.fcod.llnwd.net\/a500\/d19\/&media\/13421268001\/13421268001_1371835938001_shure-ksm-mics&1325955600000&1818a465ec2632081e214f18376d6a4d","videoCodec":"ON2","videoContainer":"FLV","videoDuration":204130},"videoFullLength":{"audioOnly":false,"controllerType":"DEFAULT","displayName":"shure_ksm_mics.flv","encodingRate":1000000,"frameHeight":480,"frameWidth":640,"id":1371835938001,"referenceId":null,"remoteStreamName":null,"remoteUrl":null,"size":29068243,"uploadTimestampMillis":1325934831973,"url":"rtmp:\/\/brightcove.fcod.llnwd.net\/a500\/d19\/&media\/13421268001\/13421268001_1371835938001_shure-ksm-mics&1325955600000&1818a465ec2632081e214f18376d6a4d","videoCodec":"ON2","videoContainer":"FLV","videoDuration":204130}}],"page_number":0,"page_size":100,"total_count":-1}

i have created below class

public class VideoList
{
    public VideoList() { }
    private string _name;
    public string Name
    {
        get
        {
            return _name;
        }
        set 
        {
            value = _name;
        }
    }
}

currently i just want to get name.
how can do this using System.Web.Script.Serialization.JavacriptSerializer class.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖哒 2025-01-01 10:54:42

我已经更改了模型结构,但这应该有效:

var serializer = new JavaScriptSerializer();
var result = serializer.Deserialize<VideoList>(json);

public class VideoList
{
    public List<Video> Items { get; set; }
}

public class Video
{
    public string Name { get; set;}

    // you can extend this class with additional propertie
    // to get the rest of json data
}

I have changed model structure, but this should work:

var serializer = new JavaScriptSerializer();
var result = serializer.Deserialize<VideoList>(json);

public class VideoList
{
    public List<Video> Items { get; set; }
}

public class Video
{
    public string Name { get; set;}

    // you can extend this class with additional propertie
    // to get the rest of json data
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文