We all know what JSON is and how it helps to build rich application. Recently during free time I was playing with JSON. It is easy to pass simple data types between server and client however its bit tricky to work with complex data types.
Consider that we have Student class with FirstName, LastName and City properties. You can pass array of Student object from client to server using JSON.stringify() method. See the code,
Fig – (1) Passing complex data type using JSON
Here we are passing array of two customer object from client to server using JSON. I have used JQUERY load method which use POST method to send the data to requested page. You can convert this parameter to Student class using following code,
Fig – (2) Generating Lsit<Student> from JSON data type