Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 674585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:43:24+00:00 2026-05-14T00:43:24+00:00

I’m using asp.net mvc2 and trying to send a list of json objects with

  • 0

I’m using asp.net mvc2 and trying to send a list of json objects with hard coded values from the home controller, and receive them in index….
in the code below i’m sending 1 json object ….
how do i send many?

in home controller:

public ActionResult JsonValue()
        { 
            var result = new 
            { 
                pID = 1, 
                pName = "Lina",
                pStart = "",
                pEnd = "",
                pColor = "ff0000",
                pLink = "",
                pMile = 0,
                pRes = "Brian",
                pComp = 0,
                pGroup = 1,
                pParent = 0,
                pOpen = 1
            };


            return Json(result,JsonRequestBehavior.AllowGet);
        }

and receiving it in index like this:

        var Jid = null;
        var Jname = null;
        var Jstart = null;
        var Jend = null;
        var Jcolor = null;
        var Jlink = null;
        var Jmile = null;
        var Jres = null;
        var Jcomp = null;
        var Jgroup = null;
        var Jparent = null;
        var Jopen = null;
        var Jtitle = null;
        var g = new JSGantt.GanttChart('g', document.getElementById('GanttChartDIV'), 'day');
        $(document).ready(function () {

            $.getJSON('../../Home/JsonValue', function (data) {
                Jid = data.pID;
                Jname = data.pName;
                Jstart = data.pStart;
                Jend = data.pEnd;
                Jcolor = data.pColor;
                Jlink = data.pLink;
                Jmile = data.pMile;
                Jres = data.pRes;
                Jcomp = data.pComp;
                Jgroup = data.pGroup;
                Jparent = data.pParent;
                Jopen = data.pOpen;
                Jtitle = '|id= ' + Jid + '|Name: ' + Jname + '|Start: ' + Jstart + '|End: ' + Jend;

            }); // end $.getJSON

thanks a million in advance…
Lina

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:43:24+00:00Added an answer on May 14, 2026 at 12:43 am

    add them to an array and return that (via the JSON call of course).

    personally I would make a class rather than the anonymous object you have and then add to a generic list, once you have the list filled you can pass the list.ToArray() into the Json call. I havent tried but you may be able to pass the list direct to the Json (I am unsure if it will create a Json array from a generic list).

    edit,

    It looks like Json will turn any enumerable into a Json array so I would say you can pass the list generic list in, I will add some code later

    code added below.

    I dont for one minute think you should code a List<object> personally, as explained I would create a class for your anonymous object so you can strongly type it. hopefully this will give you the idea though

    public ActionResult JsonValue()
            {
                List<object> jsonlist = new List<object>();
                jsonlist.Add(new
                {
                    pID = 1,
                    pName = "Lina",
                    pStart = "",
                    pEnd = "",
                    pColor = "ff0000",
                    pLink = "",
                    pMile = 0,
                    pRes = "Brian",
                    pComp = 0,
                    pGroup = 1,
                    pParent = 0,
                    pOpen = 1
                });
    
                jsonlist.Add(new
                {
                    pID = 1,
                    pName = "Lina",
                    pStart = "",
                    pEnd = "",
                    pColor = "ff0000",
                    pLink = "",
                    pMile = 0,
                    pRes = "Brian",
                    pComp = 0,
                    pGroup = 1,
                    pParent = 0,
                    pOpen = 1
                });
    
                return Json(jsonlist,JsonRequestBehavior.AllowGet);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.