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 :)
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
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?
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.
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 :)
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 :)
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.
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
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
If you can use ASP.NET 3.5, then try the JavaScriptSerializer class?
More info on MSDN.
Cheers, Lee.
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
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
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
Pete: Is xmltojson compatible with Umbraco 4.7?
is working on a reply...