First time here?

You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting!

i was working on a little sample and wanted to make it a bit easier on myself to work with my rss data.  my thought was to use the JSON format for the data and that way i could get at the data in super-cool-ajaxy-type ways.  what was cool was what i found as i began searching.

ASP.NET Ajax provides a class library to javascript!  in System.Web.Script.Serialization.JavascriptSerializer is where you will find your magic.  the JavascriptSerializer can be used on anything that uses XmlSerialization.  sweet.

so now all i had to do was take my RSS data (already in good xml format) and serialize that to xml.  once the rss is in a strongly typed respresentation using XmlSerialization, then i can pass that object to the JavascriptSerializer and voila...json formatted representation.

so my rss:

<?xml version="1.0" encoding="UTF-8"?> <channel> 
<title>Method ~ of ~ failed</title> <link>http://timheuer.com/blog/Default.aspx</link>
<description>ramblings from the digital underbelly</description>
<language>en-US</language> <copyright>timheuer</copyright>
<generator>Subtext Version</generator> ...


"Copyright":"timheuer","Description":"ramblings from the digital underbelly",
"Docs":null,"Generator":"Subtext Version", ...

wicked.  i put this in an asp.net handler file for me so now i can easily reference some rss data and immediately get back json data to work with, something like:

<script src="http://mysite/rss2json.ashx?u=http://feeds.feedburner.com/timheuer"></script>

you can get an rss serializer with this function built in over at piyush's blog.  very cool, now i can move on to my next step...

8/30/2007 10:48 AM | # re: rss and json format
check out this cool use of json and REST using SubSonic:

9/5/2007 1:05 AM | # re: rss and json format
nice and interesting.
9/6/2007 6:05 AM | # re: rss and json format
JavascriptSerializer class is marked as obsolete in NET 3.5
9/6/2007 7:38 AM | # re: rss and json format
spudz: yes it is, but if you are using 2.0 you are still good. if you are using 3.5, there is a better way i've just learned from kirk: http://blogs.msdn.com/kaevans/archive/2007/09/04/creating-a-json-service-with-webget-and-wcf-3-5.aspx
12/13/2007 12:07 PM | # re: rss and json format
What if I needed a callback function with the JSON response? Yahoo and Google JSON data feeds support callback functions.
12/14/2007 5:27 PM | # re: rss and json format
robert: i added a callback function to mine as well -- you pass it in as a param
1/14/2008 10:50 AM | # re: rss and json format

Would you be so kind as to share how you implemented and added callback function on both WCF and HTML side?

I would greatly appreciate!
1/14/2008 11:06 AM | # re: rss and json format
in my querystring i just enabled a param called 'c' and if set it would wrap the results in a function -- so it would be c=myCallback and the result from the service would be 'myCallback([data])' instead of just the pure JSON data -- this of course expects a function on your page called myCallback :-0

Please add 1 and 7 and type the answer here:


The opinions/content expressed on this blog are provided "ASIS" with no warranties and are my own personal opinions/content (unless otherwise noted) and do not represent my employer's view in any way.