Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class person
- {
- public person()
- {
- //
- // TODO: Add constructor logic here
- //
- }
- public int seq
- {
- get;
- set;
- }
- public string firstName
- {
- get;
- set;
- }
- public string lastName
- {
- get;
- set;
- }
- }
- [{"seq":1,"firstName":"Chris","lastName":"Westbrook"},
- {"seq":2,"firstName":"sayyl","lastName":"westbrook"}]
- [WebMethod]
- public void updatePeople(string json)
- {
- IList<person> people =
- new JavaScriptSerializer().Deserialize<IList<person>>(json);
- //do stuff...
- }
- var person=new object;
- person.firstName="chris";
- person.lastName="Westbrook";
- person.seq=-1;
- var data=new object;
- data.p=person;
- JSON.stringify(data);
- using System;
- using System.Collections.Generic;
- using System.Web.Script.Serialization;
- namespace Test
- {
- class Program
- {
- class Person
- {
- public int SequenceNumber { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- }
- public static void Main()
- {
- string json = "[{"SequenceNumber":1,"FirstName":"FN1","LastName":"LN1"},{"SequenceNumber":2,"FirstName":"FN2","LastName":"LN2"}]";
- IList<Person> persons = new JavaScriptSerializer()
- .Deserialize<IList<Person>>(json);
- Console.WriteLine(persons.Count);
- }
- }
- }
Add Comment
Please, Sign In to add comment