Sivakumar Chellamuthu
Sivakumar Chellamuthu

Reputation: 145

Parsing YouTube Json for Windows Store apps

I generate C# Class from http://json2csharp.com/ for any YouTube URL, in which some names are invalid like as follows:

public class Feed
{
    public string __invalid_name__xmlns$media { get; set; }
    public string __invalid_name__gd$etag { get; set; }
}

In the above code actual Youtube name is xmlns$media, gd$etag like that... when I change those to:

public class Feed
{
    public string xmlns$media { get; set; }
    public string gd$etag { get; set; }
}

in C# it shows error because of special character $, If I don't use $ parsing doesn't happens and returns Null.

Help me fixing this!

Upvotes: 0

Views: 162

Answers (1)

Jim O'Neil
Jim O'Neil

Reputation: 23764

Does this work for you?

[DataContract]
public class Feed
{
    [DataMember(Name="xmlns$media")]
    public string xmlns_media { get; set; }

    [DataMember(Name="gd$etag")]
    public string gd_etag { get; set; }
}

Upvotes: 1

Related Questions