3

Has anyone written a JSON serializer for this?

Seems a mistake to have hard-baked in the serialization functionality within this class, specificially to XmlSerializer, but I'll stand corrected as to any reasons why?

2
  • 2
    I often thought of publishing in JSON format rather than XML for MVC type applications, however I always changed my mind when I remember that Tridion manages a lot of content in XHTML format (RTF fields) and this corresponds a lot nicer (and is more easily parsed) as XML
    – Will Price
    May 28, 2013 at 22:21
  • Thanks. I guess the root of my overall question is that there are so many ways to do something I am almost 'scared' to commit for fear of it not being best practice. I guess that's the power (and pain) with Tridion, however.
    – mpaton
    May 29, 2013 at 10:07

2 Answers 2

13

The reason why the data format (in our case XML) is hardcoded, is that DD4T controls the input as well as the output of the process. The XML is intended to be consumed in a web application by the DD4T factories / providers.

If you want to publish JSON and consume it using custom application logic, you don't really need DD4T - just write a template that does this. If you just want to access the Tridion content model on the front end using Java or .NET, and you don't care about the data format in which the pages and components get published, DD4T is the framework for you.

13

As I understand it, DD4T is an open source project. Presumably no-one has yet felt the need for this enhancement. My suggestion would be to build it yourself, and obviously, also contact the DD4T team to see if your enhancement can benefit others by being integrated into the project

9
  • Looking further into this it's a bit of a waste of time anyway, as whatever comes back from OData.svc is already encoded into a string within 'content', therefore the JSON data would also be (by design) and would have to be parsed out anyway. Can output from CP's be forced to conform to a data contract on publish instead of just being chucked into a string literal?
    – mpaton
    May 28, 2013 at 20:39
  • 2
    You would have to perform the validation in your template - I do this all the time.
    – Nuno Linhares
    May 28, 2013 at 20:42
  • 3
    @mpaton - Don't feel bad about not understanding. For the record: perfection malforming algorithm correctness proofs are unlikely to execute in anything better than O(n4~*) May 28, 2013 at 21:36
  • 3
    If you do find an algorithm that can do it in O(n), please share it, because it would be good press if the P = NP proof came out of the Tridion Stack Exchange. We'd probably make it all the way out of beta! May 29, 2013 at 0:42
  • 1
    Haha, I did consider that and what I'd do with the $1m. Most of the proofs from mathematics genii seem to indicate O(n^2), however.
    – mpaton
    May 29, 2013 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.