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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:25:04+00:00 2026-05-25T16:25:04+00:00

I’m having a bit of a problem with serializing my .NET objects into JSON

  • 0

I’m having a bit of a problem with serializing my .NET objects into JSON using JSON.NET. The output I want to be serialized will have to look like this:

{"members":[

    {"member":
        {
            "id":"4282",
            "status":"1931",
            "aktiv":"1",
            "firmanavn":"firmname1",
            "firmaUrl":"www.firmurl.dk",
            "firmaUrlAlternativ":"",
            "firmaSidstKontrolleretDato":"30-08-2010",
            "firmaGodkendelsesDato":"07-03-2002"
        }
    },
    {"member":
        {
            "id":"4283",
            "status":"1931",
            "aktiv":"1",
            "firmanavn":"firmname2",
            "firmaUrl":"www.firmurl.dk",
            "firmaUrlAlternativ":"",
            "firmaSidstKontrolleretDato":"30-08-2010",
            "firmaGodkendelsesDato":"18-12-2000"
         }
},
      ...... long list of members omitted

My .NET structure for now (still experimenting to get the right output) is like this:

public class Members
{
    public List<Member> MemberList { get; set; }
}

and:

public class Member
{
    [JsonProperty(PropertyName = "Id")]
    public string Id { get; set; }

    [JsonProperty(PropertyName = "Status")]
    public string Status { get; set; }

    [JsonProperty(PropertyName = "Aktiv")]
    public string Aktiv { get; set; }

    [JsonProperty(PropertyName = "Firmanavn")]
    public string Firmanavn { get; set; }

    [JsonProperty(PropertyName = "FirmaUrl")]
    public string FirmaUrl { get; set; }

    [JsonProperty(PropertyName = "AltFirmaUrl")]
    public string AlternativFirmaUrl { get; set; }

    [JsonProperty(PropertyName = "FirmaSidstKontrolleretDato")]
    public string FirmaSidstKontrolleretDato { get; set; }

    [JsonProperty(PropertyName = "FirmaGodkendelsesDato")]
    public string FirmaGodkendelsesDato { get; set; }
}

What the above .NET structure gives me when calling:

string json = JsonConvert.SerializeObject(members, Newtonsoft.Json.Formatting.Indented);

Where ‘members’ is a list of members. Is this:

{
  "Members": [
   {
      "Id": "1062",
      "Status": "1933",
      "Aktiv": "1",
      "Firmanavn": "firmname",
      "FirmaUrl": "http://www.firmurl.dk",
      "AltFirmaUrl": "http://www.altfirmurl.dk",
      "FirmaSidstKontrolleretDato": "13-09-2011",
      "FirmaGodkendelsesDato": "13-09-2511"
   },
   {
      "Id": "1060",
      "Status": "1933",
      "Aktiv": "1",
      "Firmanavn": "firmname2",
      "FirmaUrl": "http://www.firmurl.dk",
      "AltFirmaUrl": "http://www.altfirmurldk",
      "FirmaSidstKontrolleretDato": "13-09-2011",
      "FirmaGodkendelsesDato": "13-09-2511"
   },

So basically, the structure is right in that it creates the array of members as expected, but I am missing the “member”: label on each of the member objects. Is there any way to make such a label? Some kind of class declaration, or something?

I hope my question is clear, if not – please let me know and I’ll try to explain further.

Thanks a lot in advance.

/ Bo

  • 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-25T16:25:05+00:00Added an answer on May 25, 2026 at 4:25 pm

    It sounds like you just need to make an intermediary object with a property of that name to get the JSON you want; however, I’d consider using the JSON.net originally rendered JSON (as it is structurally better).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.