Hello! There was a task to parse simple json files from a .NET application. Link to an example of such a file. I managed to see 4 arrays: "artists", "tracks", "friends", "albums".
Just a novice programmer himself, please tell me the library you need to access arrays and their contents.

    3 answers 3

    Well, for a start, a convenient online parser, just to understand the structure: json.parser.online.fr

    Well, the library itself for .Net: json.codeplex.com

    • Thank you very much! Just what you need! - turlir

    In .NET 4.0 there are standard tools for working with JSON . As an option - DataContractJsonSerializer . Here is an example of its use. Describe the data structures:

    [DataContract] public class ProfileType { [DataMember] public int ProfileTypeIDT { get; set; } [DataMember] public string SingularName { get; set; } [DataMember] public string PluralName { get; set; } [DataMember] public ProfileField[] Fields { get; set; } } [DataContract] public class ProfileField { [DataMember] public int ProfileFieldIDT { get; set; } [DataMember] public int ProfileTypeIDT { get; set; } [DataMember] public string FieldName { get; set; } [DataMember] public string DataType { get; set; } [DataMember] public int Length { get; set; } } 

    And then you deserialize the data like this:

     byte[] byteArray = Encoding.Unicode.GetBytes(jsonString); MemoryStream stream = new MemoryStream(byteArray); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ProfileType[])); ProfileType[] profileTypes = (ProfileType[])serializer.ReadObject(stream); 

      Powerful parsers:

      -ServiceStack Json Parser