How to parse array of objects

Posted on 2015-01-17 02:46:42 by Matt
Last Updated: Sep 15, 2015Views: 810Votes: 0

I have the following array of objects within my JSON file that I'm having trouble parsing:

{
    "@name": "zlib License",
    "component": [{
        "name": "iCarousel",
        "url": "http://github.com/nicklockwood/iCarousel/"
    }, {
        "name": "FXKeychain",
        "url": "http://github.com/nicklockwood/FXKeychain/"
    }, {
        "name": "FXForms",
        "url": "http://github.com/nicklockwood/FXForms/"
    }],
    "licensetext": " The zlib/libpng License Copyright (c) <year> <copyright holders> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it  and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution."
}

with this jquery loop:

function convertJson(data) {
var jsondata = data;
var output = "<ul>";
$.each(jsondata.license, function(k, lic) { 
    $.each(lic.component, function(i, comp) { 
        output += "<li><b>Name: </b>" + comp.name + " <br /> <b>URL</b> : " + "<a href=' " + comp.url + " '>" + comp.url + "</a>" + " <br /> <b>License</b><br /><ul>" + "<div class='license'>" + lic.licensetext + "</div></ul><br />" + "</li>";
    });
});
output += "</ul>";
document.getElementById("licenses").innerHTML = output;
};

convertJson(yourJson);
});

This is my current implementation, but not sure how to get the inner objects (where the name and url are showing undefined with the $.each loop: jsfiddle

a simple if() would help. What is expected result if not defined? – charlietfl Jan 16 at 21:50
If you look at the fiddle, you'll see license entries where the name and url are undefined. I'm not sure how to loop through the JSON to grab those entries, like I did for the others. – Matt Jan 16 at 21:50
where is jsondata.license coming from? I don't see it in the JSON you posted. – Jesse Kernaghan Jan 16 at 21:50
Refer to the fiddle. The JSON is too large to post in the question without it being a fiddle. – Matt Jan 16 at 21:51

2 answers

By Max Zoom

You have some invalid Json for component element - one time it is a single object, other it is an array of objects. Also some of your code need correction. I have put it all together here:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>Licenses</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    <script>
      var jsonData = {
    "@name": "Reuters TV iOS",
    "license": [{
        "@name": "OpenSSL Combined License",
        "component": [{
            "name": "OpenSSL",
            "url": "http://www.openssl.org/"
      }],
        "licensetext": "LICENSE ISSUES \r\n==============\r\n \r\nThe OpenSSL toolkit stays under a dual license, i.e. both the conditions of\r\nthe OpenSSL License and the original SSLeay license apply to the toolkit.\r\nSee below for the actual license texts. Actually both licenses are BSD-style\r\nOpen Source licenses. In case of any license issues related to OpenSSL\r\nplease contact openssl-core@openssl.org.\r\n OpenSSL License \r\n---------------\r\n \r\n==================================================================== Copyright (c) 1998-2008 The OpenSSL Project.  All rights reserved. Redistribution and use in source and binary forms, with or without\r\nmodification, are permitted  provided that the following conditions\r\nare met:\r\n Redistributions of source code must retain the above copyright\r\n   notice, this list of conditions and the following disclaimer.\r\n  Redistributions in binary form must reproduce the above copyright\r\n   notice, this list of conditions and the following disclaimer in\r\n   the documentation and/or other materials provided with the\r\n   distribution. All advertising materials mentioning features or use of this\r\n   software must display the following acknowledgment: \r\n   \"This product includes software developed by the OpenSSL Project\r\n   for use in the OpenSSL Toolkit. (http://www.openssl.org/)\" The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\r\n   endorse or promote products derived from this software without\r\n   prior written permission. For written permission, please contact\r\n   openssl-core@openssl.org. Products derived from this software may not be called \"OpenSSL\" nor may \"OpenSSL\" appear in their names without prior written permission of the OpenSSL Project.  Redistributions of any form whatsoever must retain the following\r\n   acknowledgment: \r\n   \"This product includes software developed by the OpenSSL Project\r\n   for use in the OpenSSL Toolkit (http://www.openssl.org/)\" \r\nTHIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT \"AS IS\" AND ANY\r\nEXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r\nPURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\r\nITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r\nSTRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\r\nOF THE POSSIBILITY OF SUCH DAMAGE. \r\n====================================================================\r\n \r\nThis product includes cryptographic software written by Eric Young\r\n(eay@cryptsoft.com).  This product includes software written by Tim\r\nHudson (tjh@cryptsoft.com).\r\n &nbsp; Original SSLeay License \r\n -----------------------\r\n Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) \r\nAll rights reserved. \r\nThis package is an SSL implementation written\r\nby Eric Young (eay@cryptsoft.com). \r\nThe implementation was written so as to conform with Netscapes SSL.\r\n \r\nThis library is free for commercial and non-commercial use as long as\r\nthe following conditions are aheared to.  The following conditions\r\napply to all code found in this distribution, be it the RC4, RSA,\r\nlhash, DES, etc., code; not just the SSL code.  The SSL documentation\r\nincluded with this distribution is covered by the same copyright terms\r\nexcept that the holder is Tim Hudson (tjh@cryptsoft.com).\r\n\r\nCopyright remains Eric Young's, and as such any Copyright notices in\r\nthe code are not to be removed. \r\nIf this package is used in a product, Eric Young should be given attribution\r\nas the author of the parts of the library used. \r\nThis can be in the form of a textual message at program startup or\r\nin documentation (online or textual) provided with the package.\r\n Redistribution and use in source and binary forms, with or without\r\nmodification, are permitted  provided that the following conditions\r\nare met:\r\n Redistributions of source code must retain the copyright\r\n   notice, this list of conditions and the following disclaimer.  Redistributions in binary form must reproduce the above copyright\r\n   notice, this list of conditions and the following disclaimer in the\r\n   documentation and/or other materials provided with the distribution. All advertising materials mentioning features or use of this software\r\n   must display the following acknowledgement: \r\n   \"This product includes cryptographic software written by\r\n    Eric Young (eay@cryptsoft.com)\" \r\n   The word 'cryptographic' can be left out if the rouines from the library\r\n   being used are not cryptographic related :-).  If you include any Windows specific code (or a derivative thereof) from\r\n   the apps directory (application code) you must include an acknowledgement:\r\n   \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\r\n \r\nTHIS SOFTWARE IS PROVIDED BY ERIC YOUNG \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\nARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r\nOR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r\nSUCH DAMAGE.\r\n \r\nThe licence and distribution terms for any publically available version or\r\nderivative of this code cannot be changed.  i.e. this code cannot simply be\r\ncopied and put under another distribution licence\r\n[including the GNU Public Licence.]"
    }, {
        "@name": "SIL Open Font License 1.1",
        "component": [{
            "name": "Font-Awesome",
            "url": "http://github.com/FortAwesome/Font-Awesome/"
      }],
        "licensetext": "  SIL OPEN FONT LICENSE  Version 1.1 - 26 February 2007  PREAMBLE The goals of the Open Font License (OFL) are to stimulate worldwide\r\ndevelopment of collaborative font projects, to support the font creation\r\nefforts of academic and linguistic communities, and to provide a free and\r\nopen framework in which fonts may be shared and improved in partnership\r\nwith others. The OFL allows the licensed fonts to be used, studied, modified and\r\nredistributed freely as long as they are not sold by themselves. The\r\nfonts, including any derivative works, can be bundled, embedded, \r\nredistributed and/or sold with any software provided that any reserved\r\nnames are not used by derivative works. The fonts and derivatives,\r\nhowever, cannot be released under any other type of license. The\r\nrequirement for fonts to remain under this license does not apply\r\nto any document created using the fonts or their derivatives.  DEFINITIONS \"Font Software\" refers to the set of files released by the Copyright\r\nHolder(s) under this license and clearly marked as such. This may\r\ninclude source files, build scripts and documentation. \"Reserved Font Name\" refers to any names specified as such after the\r\ncopyright statement(s). \"Original Version\" refers to the collection of Font Software components as\r\ndistributed by the Copyright Holder(s). \"Modified Version\" refers to any derivative made by adding to, deleting,\r\nor substituting &mdash; in part or in whole &mdash; any of the components of the\r\nOriginal Version, by changing formats or by porting the Font Software to a\r\nnew environment. \"Author\" refers to any designer, engineer, programmer, technical\r\nwriter or other person who contributed to the Font Software. PERMISSION &amp; CONDITIONS Permission is hereby granted, free of charge, to any person obtaining\r\na copy of the Font Software, to use, study, copy, merge, embed, modify,\r\nredistribute, and sell modified and unmodified copies of the Font\r\nSoftware , subject to the following conditions: 1)  Neither the Font Software nor any of its individual components,\r\nin Original or Modified Versions, may be sold by itself. 2) Original or Modified Versions of the Font Software may be bundled,\r\nredistributed and/or sold with any software , provided that  each copy\r\ncontains the above copyright notice and this license. These can be\r\nincluded either as stand-alone text files, human-readable headers or\r\nin the appropriate machine-readable metadata fields within text or\r\nbinary files as long as those fields can be easily viewed by the user. 3)  No Modified Version of the Font Software may use the Reserved Font\r\nName(s) unless explicit written permission is granted by the corresponding\r\nCopyright Holder. This restriction only applies to the primary font name as\r\npresented to the users. 4)  The name(s) of the Copyright Holder(s) or the Author(s) of the Font\r\nSoftware shall not be used to promote, endorse or advertise any\r\nModified Version, except to acknowledge the contribution(s) of the\r\nCopyright Holder(s) and the Author(s) or with their explicit written\r\npermission. 5)  The Font Software, modified or unmodified, in part or in whole,\r\nmust be distributed entirely under this license, and must not be\r\ndistributed under any other license. The requirement for fonts to\r\nremain under this license does not apply to any document created\r\nusing the Font Software. TERMINATION This license becomes null and void if any of the above conditions are\r\nnot met. DISCLAIMER THE FONT SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\r\nOF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE\r\nCOPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r\nINCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL\r\nDAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r\nFROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM\r\nOTHER DEALINGS IN THE FONT SOFTWARE. "
    }, {
        "@name": "zlib License",
        "component": [{
            "name": "iCarousel",
            "url": "http://github.com/nicklockwood/iCarousel/"
        }, {
            "name": "FXKeychain",
            "url": "http://github.com/nicklockwood/FXKeychain/"
        }, {
            "name": "FXForms",
            "url": "http://github.com/nicklockwood/FXForms/"
        }],
        "licensetext": " The zlib/libpng License Copyright (c) &lt;year&gt; &lt;copyright holders&gt; This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it  and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution."
    }],
    "isProjectComplete": "true"
    };

    function convertJson(jsondata) {
      var output = "<ul>";
      $.each(jsondata.license, function(k, lic) {
        output += '<li>';
        $.each(lic.component, function(k, comp) {
          output += "<b>Name: </b>" + comp.name + " <br /> <b>URL</b> : " + "<a href=' " + comp.url + " '>" + comp.url + "</a>" + " <br />";
        });
        output += "<b>License</b><br /><ul>" + "<div class='license'>" + lic.licensetext + "</div></ul><br />" + "</li>";
      });
      output += "</ul>";
      $("#licenses").html(output);
    };

    $(document).ready( function() {
      convertJson(jsonData);
    });
    </script>
  </head>
  <body>
    <div id="licenses"></div>
  </body>
</html>

By AndreasBest answer

Either change the structure of the JSON so that single components will also be wrapped in an array or adjust convertJson()

function convertJson(data) {
    //...
    $.each(jsondata.license, function(k, lic) {
        var components = lic.component.length ? lic.component : [lic.component];  // <- this

        $.each(components, function(i, comp) { 
            //...
        });
    });
    //...
};

fiddle

2 similar answers  β 

By syarul

well sorry, this is the answer, which is pretty silly for me. When the variable is an array of objects simply use join() to add lines breaks. So the output will nicely become text file with all array objects appear on new lines.

var arr = ['firstline', 'secondline', 'thirdline'];
var lineConcat = arr.join("\r\n");
var blob = new Blob([lineConcat], {type: "application/txt"});

By HarryH

I threw some javascript into a plunkr to emulate what it would be like. Just open up the console and run the code. You should see it going through and returning the data of Mondial Orders.

http://plnkr.co/edit/22qyZox6WJLsv5qS2n11?p=preview

var req = {};
//Emulate orders in req
req.body = [
    {Order: {Type: 'Mondo Cool', Company: 'Mondial'}},
    {Order: {Type: 'Moo', Company: 'Cow Guys'}},
    {Order: {Type: 'Woof', Company: 'Dog Guys'}},
    {Order: {Type: 'Mondo Bacon', Company: 'Mondial'}},
    {Order: {Type: 'Bawk Bawk', Company: 'Cat Guys'}},
    {Order: {Type: 'Mondo Cheese', Company: 'Mondial'}},
];

//Fill in a mock db
var db = 'mockDb';

//Import Orders
var importOrders = function(req, res, next){
    var orders = req.body;
    var processOrder = function () {
      if(i < orders.length){
          if(orders[i].Order.Company === "Mondial"){
            parseMondial(db, orders[i].Order, processOrder);
            i++;
          } else{
            i++;
            processOrder();
          }
      } else {
        //Mocks ending the loop and perform final res.send()
         console.log('res.send');
      }
    };
    var i = 0;
    processOrder();
};

//Emulates parseMondial and async request/queries
function parseMondial(db,order,callback,log){
  //Do something with order asyncrounously
  setTimeout(function(){
    console.log(order);
    console.log('Did a query and waited for the response ' + order.Company);
    callback();
  }, 1000);
}

//Mock making a req to importOrders
importOrders(req,null,null);  

Once the code in parseMondial completes, you can call the callback and if you need to you can pass data. However, it may not have reference to i or orders within parseMondial, so to be safe, I handled passing the orders and iterating the index outside of parseMondial.

Passing in processOrders() isn't a callback. Passing processOrders provides it as a function that can be called at the end of parseMondial.

I took out some of the try/catch stuff just to make the code simpler to read and use to your purposes.

Similar Posts
Parse through array of objects
Happy CoderVotes: 0Relevancy: 94%
I am getting the following array of objects as response when printing a variable called userStatistic. How can I parse through this and get the value of created_at and the other things.? I have tried to use userStatistic->created_at. But it is not returning anything. Then I tried with userStatistic[0]->created_at. But it is throwing Fatal error as How can I parse through this mixed variable ?? NB .
Design Pattern to parse array of objects
Vlad SpreysVotes: 2Relevancy: 91%
What is considered a good practice to parse an array of objects returned by an API? I am creating a RESTfull web service and a client which is meant to work with this service. One of my REST services returns a JSON array in the following format. In my client I would like to parse this JSON array and map it to the model, but I am not sure where to place the parsing logic to keep the loose coupling. What I already have.
Retrieve Parse Array of Objects in Swift
Clifton LabrumVotes: 0Relevancy: 88%
I'm storying an array of JavaScript key/value objects in a column of type Array on Parse like this. When I retrieve that column in Swift, I can see the data, but I'm unsure what data type to cast it as. That print yields this in the console (for the first pair). I can't seem to cast its contents as a Dictionary [Int. Double] and I'm guessing that means this is a string. How do I parse this data in Swift? Thanks.
Retrofit + GSON parse an Array of objects
ChronosVotes: 0Relevancy: 85%
I receive this jason as a response from a WS. Notice that there are no name-value fields the json is an array of strings arrays.I tried several attemps to parse the response. I tried with a pojo with a List of strings but I have the same error always. retrofit.RetrofitError. com.google.gson.JsonSyntaxException. java.lang.IllegalStateException. Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path MyPOJO for retrofit callback is the next one.
how to jquery parse array in elements?
user2773795Votes: -3Relevancy: 82%
I have a problem about parse data json, ajax. Example. how to parse data like thank you for the answer.
AJAX, JQuery, Parse - which one will get me my array?
dwilbankVotes: 0Relevancy: 79%
In my codeacademy and codeschool lessons, I've been fetching data from google rss and simulated twitter feeds. My newest exercise, however, involves fetching an array of text data from a REST API. When I try I get which has the text and username I need. Sort of... but when I try to alert or console.log either *x.responseText or x.responseText.results I obviously get undefined instead of an array.
How to access this. property inside jquery plugin array of objects
LeronVotes: 0Relevancy: 76%
I'm trying to create wrapper around the jquery datatable so I wrap everything inside this . the customOptions are optinal so I check if custom options are used and if not I make Ajax call to the back end for the default settings. And here comes the problem. I need to manipulate some of the data that got back from the server. In this array of objects - options.aoColumns I may or may not have se property Render.
jquery filter array of objects to find object property with highest value
Trevor OrrVotes: 0Relevancy: 73%
Is there a way to use the filter function to find an object in an array of objects with a property of the object having the highest or lowest value in the array? So if I have the follow. I was wondering if you could use the filter command to find the item with the highest or lower xpos or ypos?
jquery send array of objects
user2821171Votes: 0Relevancy: 70%
I have an array of objects... One object contains. How can I send this with a POST. It currently returns "null", and data in Controller is also null.. I tried to use dataType JSON, and also serialize, and STRINGIFY, doing json.stringify gave me null too.
use jquery to store array of objects and pass it to server through ajax call
ChethanVotes: -2Relevancy: 67%
In my scenario i need to store some values in arrays of c# object and set some values to those. Then i need to store those values to database through ajax call. Please help me Any suggestions. I have around three objects available all need to go to database. There will be form kind of area where user will be adding controls like textbox, textarea,fieldset, section etc., by drag and drop functionality. For each of this elements the name of textbox for eg.
JQuery autocomplete with Array of Objects built with PHP+MySQL
Nuno NogueiraVotes: 0Relevancy: 64%
I have a MySQL table like. In Jquery, I'm able to use autocomplete showing "name" in the pop-up list while inserting the "id" in the input. This is working fine, but now I need to reproduce the array of objects "names" using PHP. I'm trying the following in PHP. This is returning. In Jquery, I'm now using Ajax to call myscript.php. But this is just displaying the same result in the cell.
Return value of a JQuery autocomplete using an array of objects as its source
user2920430Votes: 1Relevancy: 61%
In a JQuery autocomplete which uses an array of objects as its source, can I display the label in the INPUT and later access the value? The default behavior is that the value is displayed in the INPUT after selection. In this case the values represent indexes to unique keys in rows in a table.
Why jQuery.inArray doesn't work on array of objects
cossetVotes: 3Relevancy: 58%
I have array of objects I need get index, for example, for object with id="2".I do In index I get -1. JsFiddle
Pass Variables to JQuery Waypoints
user2584980Votes: 2Relevancy: 55%
I'm trying to use JQuery Waypoints to do a colour-changing header. I have an array of objects showing sections of the one-page site with their relevant colours (see below). I am then using the script below to create JQuery Waypoints for each section (which are marked up as <section id="..."> in the HTML). When I just manually created waypoints for each section instead of using an array of objects and a for loop, it worked, but this was a lot of code repetition.
Jquery fade in array of objects - items one at a time
MeowpheusVotes: 0Relevancy: 52%
Learning a lot about Jquery every day. However it seems I can't for the life of me figure out how to display items in this multidimensional array one item at a time, while fading in and out of each one. *Note I don't wants these to append, just display one set, then fade out and fade in to the next set. Here's some info for you pros. Basically Here I am storing what I have in my json Object named data into result.
jQuery $.each for specific keys within an array of objects
MakisVotes: 0Relevancy: 49%
I have this array of objects below and i want to iterate with .each and get the type and description
Parse PHP array of objects with jQuery Ajax
Christopher KarlssonVotes: 1Relevancy: 46%
I'm trying to get an array of objects with data from my database into jquery to render on a website. ex. example.php exindex.html Output. console.log(response); ["test", family. function, constructor. function, each. function, clone. function, clean. function…] console.log(response[0].example); undefined So essentially, I receive the response fine, when I log it it gives me a structure that makes sense.
jQuery Parsing JSON Objects and Array
Ganesh YoganandVotes: 3Relevancy: 43%
In the following code. The data sent as response is as follows- The json array inside of mc is as shown below- I am trying to parse each object in it using jquery, and each object is as follows- To get the above object I using the following jquery code- That is each and every time of .each should get me-
Receive and parse JSON objects in controller
AndrewVotes: 0Relevancy: 40%
I am sending an array of json objects with jQuery to a controller in asp.net mvc3. The problem is when I receive the stringified version of the objects on the server because it looks null. When I receive the json I want it to be converted to a list of models. The json I send is. What I want is to have that json string converted to a list of two Model objects.

ScriptScoop

Learn it, then use it.

Social Links

Counter