Developer Forum »
JSON version of contents
58 posts

Is it possible to access JSON versions of the content-types? It's being used in OData, is that a publically accessible function? In addition, it would be very nice to be able to apply attributes to properties in the ontology module.

120 posts

You can do it using the OData endpoint. Enable the OData endpoint and add ?$format=JSON to the url.

Here is a javascript example:

View the HTML source code.

Here is a URL that returns a JSON document for a particulat content:$format=JSON

See for more info!

58 posts

Ok, so it is not possible to access some sort of method like Object.ToJson() or the likes?


120 posts

Well, not directly. There is however a simplified version of each content class if you look closer at the odata endpoint file in app_code. It should be possible to serlialize these classes to JSON, but you are moving into "non standard" use of the odata classes and we cannot guarantee these odata classes will change. Most likely they will change and break your functionality at some later update.

20 posts

I "solved" this by creating our own JSON objects in .NET (which only contains the data we wish to expose), and using Jimmy Bogards legendary AutoMapper to map from WebNodes classes to JSON Classes. 

Finally i serialzed the JSON classes using System.Web.Script.Serialization.JavaScriptSerializer. I used an ashx handler for this.


public void ProcessRequest(HttpContext context) {

    AutoMapper.Mapper.CreateMap<ArgusBlankett, JSONBlankett>();

    List<JSONBlankett> jsonList = AutoMapper.Mapper.Map<List<ArgusBlankett>,          



    JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

    string jsondata = javaScriptSerializer.Serialize( jsonList  );


    context.Response.ContentType = "application/json";

    context.Response.ContentEncoding = System.Text.Encoding.UTF8;