Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Duncanson 430 posts 1360 karma points c-trib
    Mar 09, 2010 @ 16:34
    Peter Duncanson
    0

    Convert XML to JSON in Umbraco?

    Working on some Ajax goodness, currently I'm returning the HTML for the content of a panel, I'd like to return just JSON though. Any nice methods built into Umbraco for converting XML to JSON? I know there is XML2JSON XSL which might do the job and there are a number of .net converters too.

    Before I dig much deeper thought it worth an ask :)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 09, 2010 @ 16:41
    Lee Kelleher
    2

    Hi Peter,

    Nothing that I know of in the Umbraco core... but going off my old forum post, there's a newer version of "xmltojson":

    http://forum.umbraco.org/yaf_postst6281_Convert-XML-2-JSON-via-XSLT.aspx

    http://code.google.com/p/xmltojson/

    Cheers, Lee.

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Mar 10, 2010 @ 11:01
    Ismail Mayat
    1

    Peter,

    You could use http://json.codeplex.com/ to aid you to convert xml to json, you put together POCO class and decorate it with attributes then get your xml and fill object then run it through json.net

    to give you json.

    Regards

     

    Ismail

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Mar 10, 2010 @ 19:09
    Peter Duncanson
    0

    The more I look into this the more I want to create a plugin for it. Defo going to do it in C# as it will be faster. Let another thing to add to me list of "todos".

    Ismail are you going to pop over for the Huddersfield Meet on the 25th?

    Pete

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 10, 2010 @ 19:25
    Lee Kelleher
    0

    If you can use ASP.NET 3.5, then try the JavaScriptSerializer class?

    System.Web.Script.Serialization.JavaScriptSerializer

    More info on MSDN.

    Cheers, Lee.

  • Neil Campbell 58 posts 182 karma points
    Mar 11, 2010 @ 03:14
    Neil Campbell
    1

    Hi Pete,
    If you are running .NET framework version 2, then have a look at Newtonsoft.Json.

    I have used this for rendering umbraco node data into a serialised JSON file.

    Hope this helps.
    Neil

     

     

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Mar 11, 2010 @ 18:38
    Peter Duncanson
    0

    Thanks Neil, had a play with Newtonsoft.Json last night and created an extension which give some handy JSON calls from within my XSL. I'll be using this as its working a treat. Just need to wrap it up and then I'll roll it out as a package once back from my holidays next week.

    Cheers for the help guys.

    Pete

  • Peter Duncanson 430 posts 1360 karma points c-trib
    May 26, 2010 @ 18:51
    Peter Duncanson
    2

    I've blogged about my solution to this and the package we released to make it easier for others. Putting it here for history (and google hunters) sake :)

    www.offroadcode.com/2010/5/26/xsltojson-a-handy-little-package.aspx

    or 

    our.umbraco.org/projects/xsltojson if you just want the package

    Cheers

    Pete

  • Matt Gilbert 24 posts 44 karma points
    Jul 06, 2011 @ 20:22
    Matt Gilbert
    0

    Pete: Is xmltojson compatible with Umbraco 4.7?

Please Sign in or register to post replies

Write your reply to:

Draft