.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Deserializing a JSON array of mixed types

Posted By:      Posted Date: October 10, 2010    Points: 0   Category :WCF


I'm having trouble deserializing a JSON array of mixed types using the DataContractJsonSerializer class. I've spent a bunch of time looking for a solution to no avail, so I thought I'd go ahead and ask here.

Basically, I am getting a JSON string like the one below. I'd like to get the array to deserialize into an List where position 0 has an Int32, position 1 has a String, and position 2 has an instance of my custom class.

"Mr. Smith",
"name":"main street",

View Complete Post

More Related Resource Links

Serializaing/deserializing XOMLs with custom activities that have properties of ISerializable types

I have custom activities that have dependency properties of types that implement ISerializable. When they are serialized/deserialized to XOML, the ISerializable-implied functionality is ignored and the standard reflection-based SerializableAttribute behavior is invoked. This poses a serious problem since the types require precise control over their serialization to ensure that proper internal state is maintained across serialization boundaries. I am aware of the WF custom serialization methods as mentioned in Tom Lakes' blog post, but they seem to require the DesignerSerializerAttribute attribute on all custom types. This is a problem because the types are business objects shared across many (non-WF) applications and they are part of a seperate code base to which I have no access. Is there a different method for getting custom serialization? And what is the reasoning behind the WF team choosing to ignore the very basic ISerializable attribute which is supported by every other .NET API across the framework? Thanks in advance.

MVC - Return Array Json

  function SaveDataToArray1(VungNguyenLieu, DienTich,LoaiGiong,
                                 SanLuong, TGXuongGiong, TGThuHoach) 
            var arr = new Array(arrData.length,
                                VungNguyenLieu, DienTich,LoaiGiong,
                                 SanLuong, TGXuongGiong, TGThuHoach);

        function ReloadGrid1() {
            $('#tbNoiDung tbody').html("");
            for (i = 0; i < arrData1.length; i++) {
                var tbRow = "<tr>";
                tbRow += "<td align=\"center\">" + (i + 1) + "</td>";
                tbRow += "<td align=\"center\">" + arrData[i][1] + "</td>";
                tbRow += "<td align=\"center\">" + arrData[i][2] + "</td>";
                tbRow += "<td align=\"center\">" + arrData[i][3] + "</td>";
                tbRow += "<td align=\"center\">" + arrData[i][4] + "</td>";
                tbRow += "<td align=\"center\">" + arrData[i][5] + "</td>";
                tbRow += "<td align=\"center\"

Sending JSON Array to an ASP.NET MVC Action Method Argument


 <input type = "submit" onclick = "savePayment()"  value = "Test"/>

    <script type="text/javascript">
        function savePayment() {
            //Creating some test data
            var lineItems = new Object();
            lineItems.Entrys = new Array();
            lineItems.Entrys[0] = new Object({ Name: "Dung", Age: "21"});
            lineItems.Entrys[1] = new Object({ Name: "An", Age: "25" });

            //Posting them to server with ajax
                type: 'POST',
                contentType: 'application/json; charset=utf-8',
                url: '<%=Url.Action("TestArray", "Json") %>',
                dataType: 'json',
                data: $.toJSON(lineItems),
                success: function (result) {
                    if (result) {
                    else {

json array


i am new to json array... i cant understand one bit of this concept

i am pasting a code here. can any1  explain me this code

if (Request.QueryString["Tab"] == "Overview")
                sReturnVal = "{\"array_list\":{\"list\":[";
                sReturnVal += "{\"Source\":'" + Request.QueryString["Tab"] + "'}]";
                string strVal = "";

Trying to understand Array being reference types


Below I'm pasting a simple application to roll 5 die 10 times and display each roll on screen.  the problem I'm having is that the output will look like this


3  4  6  3  1
3  4  6  3  1
3  4  6  3  1

but when i step through I different values for each roll

Here's the code


namespace DiceRoller
    class DiceManager
        private int numOfDice;
        private int[] diceRoll;

        public DiceManager(int numOfDice)
            NumOfDice = numOfDice;

        public int NumOfDice
            get { return numOfDice; }
            set { numOfDice = value; }

        public int[] DiceRoll
            get { return diceRoll; }
        // Roll dice and sets the diceRoll Array to values between 1 and 6.
        private void RollDice()
            diceRoll = new int[NumOfDice];
            Random rand = new Random();
            for (int i = 0; i < diceRoll.Length; i++)
                diceRoll[i] = rand.Next(1, 6);

        public void DisplayResults()
            foreach( int dieValue in diceRoll )
                Console.Write("{0}\t", dieValue);

SharePoint Tutorial - Content Types

SharePoint content types provide users with a way to manage and organize content in a more meaningful way. It's a reusable of settings you want to apply to a particular type of document in a library or item in a list.

UML Diagram Types

UML provides a number of diagram types as a mechanism for entering model elements into the model and showing overlapping sets of models elements and their relationships. UML does not specify what diagrams should be created or what they should contain, only what they can contain and the rules for connecting the elements. The diagram types include:

UML Diagram Types - 2

Further diagram types include:

Activity Diagrams - a generic flow chart used much in business modelling and sometimes in use case modelling to indicate the overall flow of the use case. This diagram type replaces the need for dataflow diagrams but is not a main diagram type for the purposes of analysis and design.

Ready made List Types provided by SharePoint

SharePoint provides some out of the box List Types. Some of the most used ready made list types that SharePoint provides currently are listed below:

Tuples, Anonymous Types, and Concrete Types

Tuples can save you a great deal of repetitive tasks. They can also lead to completely unreadable code in a language like C#. Tuples are data values that contain N items. The .NET framework supports tuples containing 1 to 8 members. To use tuples with more than 8 members, you use another tuple for the member of an octtuple

Content Types in MOSS 2007

In this article I will try to describe the one of the best feature in Microsoft office Share Point 2007 called Content Types.

Content types are simply collection of contents.Each content in a Content type can have different settings.Basically it is a reusable collection of settings which you want to apply to a particular category of contents.

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.

Different types of applications in WPF

With Windows Presentation Foundation coming closer to its release date with Vista almost being upon us, more and more people are taking a look at programming in WPF

Date and Time Data Types and Functions

The following sections in this topic provide an overview of all Transact-SQL date and time data types and functions. For information and examples that are common to date and time data types and functions

Frequently Asked Questions - SQL Server Data Types

This is good and precise introduction and Frequently Asked Questions - SQL Server Data Types

Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend