Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5.  
  6. using Newtonsoft.Json;
  7. using Newtonsoft.Json.Serialization;
  8.  
  9. public static class JsonExtensionMethods
  10. {
  11. public static String ToJson(this object model)
  12. {
  13. JsonSerializerSettings settings = new JsonSerializerSettings
  14. {
  15. NullValueHandling = NullValueHandling.Ignore,
  16. ContractResolver = new CamelCasePropertyNamesContractResolver(),
  17. };
  18. return JsonConvert.SerializeObject(model, Formatting.Indented, settings);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement