Skip to content

Instantly share code, notes, and snippets.

@andrewconnell
Created December 9, 2014 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewconnell/1221887e8d5fbe532f66 to your computer and use it in GitHub Desktop.
Save andrewconnell/1221887e8d5fbe532f66 to your computer and use it in GitHub Desktop.
XML vs. JSON Serialization in Server Side Code - Snippet 3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
namespace TasksWeb.Models {
public class SpTaskJsonCollection {
[JsonProperty(PropertyName = "d")]
public DataCollectionReponse Data { get; set; }
}
public class SpTaskJsonSingle {
[JsonProperty(PropertyName = "d")]
public SpTaskJson Data { get; set; }
}
public class DataCollectionReponse {
[JsonProperty(PropertyName = "results")]
public SpTaskJson[] Results { get; set; }
}
public class SpTaskJson {
public __Metadata __metadata { get; set; }
public int Id { get; set; }
public string Title { get; set; }
public string Priority { get; set; }
public string Status { get; set; }
public int ID { get; set; }
}
public class __Metadata {
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "uri")]
public string Uri { get; set; }
[JsonProperty(PropertyName = "etag")]
public string ETag { get; set; }
[JsonProperty(PropertyName = "type")]
public string Type { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment