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 7775157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:33:31+00:00 2026-06-01T17:33:31+00:00

I have a question on a MVC4 (beta) issue I have been struggling with

  • 0

I have a question on a MVC4 (beta) issue I have been struggling with for some time now. The issue is that I want to create a json with the object name added for my webapi. The json has to be created this was as the receiving side needs this. My .NET/MVC knowledge is limited so please bear with me. I tried searching on the subject, but as MVC4 is still in beta it’s difficult to find good info on this subject.

I have already imported the JSON.NET formatter in my solution, but this does not add the Object name

The json that is now created in MVC4:

[{"ID":36,"Name":"Test3","Description":"Description Test3"},{"ID": 37,"Name": "Test4","Description": "Description Test4"}]

And I would like the json to look like this:

{"Goal":[{"ID":36,"Name":"Test3","Description":"Description Test3"},{"ID": 37,"Name": "Test4","Description": "Description Test4"}]}

So I like the object name (Goal) to be included in the json.

The code in my api controller I am using for this is:

    StoreDBContext db = new StoreDBContext();

    //
    // GET /api/goals
    public IQueryable<Goals> Get()
    {
        return db.Goals;
    }

I assume I need to loop through somewhere to add the object name, but I am not sure how… Hopefully someone can help me out with this!

  • 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-06-01T17:33:33+00:00Added an answer on June 1, 2026 at 5:33 pm

    Return something like this:

    new { Goal = db.Goals().AsEnumerable().ToList() }
    

    You can use an anonymous object to add properties and stuff that aren’t in the object.

    You can also write custom converters for JSON.NET if you want it to deserialize properly, but if you don’t care about deserialization of the output, the above solution will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question to Java or C# programmers. I want to render some pages
i have question about YAJLiOS parser... I have next json data : {{ body
I have question with this same title here but now as I'll present in
I have question about database optimizing, indexing. I have table that called projects and
I have question about integrate Open office with PHP. I want make mail merge
I have question about the beta Open Graph stuffs. The documentation I am looking
I have question that if I have date as string in one column of
I have question for you ... I have UITableView and I want to catch
I have question on controlling the amount of concurrent threads I want running. Let
I have question about python and sqlite3. I want to drop a table from

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.