How to parse my json string in C#(4.0)using Newtonsoft.Json package?

前端 未结 4 490
温柔的废话
温柔的废话 2020-12-29 02:48

I am new to JSON.In my asp.net application i want to parse the json string.So, i have used Newtonsoft.Json package for reading and writing json data.Now, i can able to parse

4条回答
  •  鱼传尺愫
    2020-12-29 03:06

    You could create your own class of type Quiz and then deserialize with strong type:

    Example:

    quizresult = JsonConvert.DeserializeObject(args.Message,
                     new JsonSerializerSettings
                     {
                         Error = delegate(object sender1, ErrorEventArgs args1)
                         {
                             errors.Add(args1.ErrorContext.Error.Message);
                             args1.ErrorContext.Handled = true;
                         }
                     });
    

    And you could also apply a schema validation.

    http://james.newtonking.com/projects/json/help/index.html

提交回复
热议问题