public JToken GetPage(int id) { // Get data and type it var page = _umbracoService.TypeGenericToModelsBuilderType(Umbraco.Content(id)); // Json settings var jsonSerializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new PublishedContentContractResolver(), }; jsonSerializerSettings.Converters.Add(new HtmlStringConverter()); var data = Newtonsoft.Json.JsonConvert.SerializeObject(page, jsonSerializerSettings); return(JToken.Parse(data)); }
public JToken GetAllRoutes(int?rootId) { var root = rootId.HasValue ? Umbraco.Content(rootId) : Umbraco.ContentAtRoot().First(); var descendants = root.Descendants().ToList(); descendants.Add(root); descendants = _umbracoService.TypeGenericToModelsBuilderType(descendants); // Json settings var jsonSerializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new PublishedContentContractResolver(), }; jsonSerializerSettings.Converters.Add(new HtmlStringConverter()); var data = Newtonsoft.Json.JsonConvert.SerializeObject(descendants, jsonSerializerSettings); return(JToken.Parse(data)); }