Here is how to consume a JSON object in Silverlight 2.
- Start with a JSON object:
var Person = {
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
}
} - Create an entry point into Silverlight. You will need to add namespace System.Windows.Browser.

- Next add C# classes to mirror the JSON object. It’s important to make sure the variables in the class are exactly how they appear in the JSON object, this is case sensitive.

- Before adding the deserializing code, add references in your project for System.Runtime.Serialization, System.ServiceModel, and System.ServiceModel.Web.

- Now that the proper references are made in the project, we can finally write the code that deserializes the JSON object. The class that does all the magic is System.Runtime.Serialization.Json.DataContractJsonSerializer.

- Finally add some HTML and JavaScript to make this work. (To get the JSON object in a serialized form I am using the Prototype JavaScript library. That is where you’ll find the function Object.toJSON(). There are other ways to serialize a JSON object. Notably, if you are using the AJAX ASP.NET library, there is a function in there that does exactly the same thing as this call.)JavaScript
function sendJSON(){ document.getElementById("SL").Content.Bridge.SendJSON(Object.toJSON(Person)); }
HTML
<input type="button" value="send JSON to SL" onclick="sendJSON()" id="btnSendJSON" />



March 12th, 2008 at 1:06 pm
[...] Consume a JSON Object in Silverlight (Corey Schuman) [...]
December 13th, 2008 at 12:44 am
[...] In this sample I’m just passing the JSON data back to my Silverlight application as a string. You’re not on your own dealing with parsing that string, though – the System.Runtime.Serialization.Json namespace can handle that for you. Corey Schuman’s written a nice walkthrough on how to consume a JSON object in Silverlight. [...]
May 15th, 2009 at 8:58 am
You might want to try this:[DataMember(Name="firstname")]public string FirstName { get; set; }It worked for meBaka
September 2nd, 2009 at 7:08 am
So you want to try your hand at online money making using blogs huh? http://feeds.ezinearticles.com/expert/Chris-Rasmussen.xml