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

  • SEARCH
  • Home
  • 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 8708549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:09:54+00:00 2026-06-13T04:09:54+00:00

In my MVC-4 Web-API server, I receive a Json string that contains spaces in

  • 0

In my MVC-4 Web-API server, I receive a Json string that contains spaces in it’s names:

{ "field name" : "some value" , "simpleName" : "some string" }

I defined a Model class, e.g:

public class SomeJsonModel
{
    [DataMember(Name = "field name")]
    public string FieldName { get; set; }

    public string SimpleName { get; set; }
}

Now SimpleName passes through (in spite it’s first letter capitalization mismatch, which is good), but FieldName becomes null.

How can I successfully receive Json that has spaces in it’s fields’ names (predefined – I cannot change the client data source) ?

  • 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-13T04:09:55+00:00Added an answer on June 13, 2026 at 4:09 am

    Try adding [DataContract] on your class:

    [DataContract]
    public class SomeJsonModel
    {
        [DataMember(Name = "field name")]
        public string FieldName { get; set; }
    
        [DataMember]
        public string SimpleName { get; set; }
    }
    

    Here is more info about this:

    • on MSDN: “Apply the DataMemberAttribute attribute in conjunction with the DataContractAttribute to identify members of a type that are part of a data contract.“
    • a Json.NET issue relating to the DataMember’s Name property being ignored. The resolution for that was to “Put DataContract on the class.“
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All of my datamodels have field DateAdded. When the user (through MVC Web API)
I'm using MVC web Api for RESTful purpose. My controller methods return serialized Json
I have MVC-4 Web-API server, and I need to create HTTP client by hand
I'm building a RESTful web api with asp.net mvc, which returns pure json data.
I have a MVC Web Api Controller that uses the [Authorize] attribute at the
I am developing some sort of service using asp.net mvc 4 web api. On
My server is a REST platform (built with asp.net MVC 4 web api), and
Below is my Get method of MVC Web Api RC. public Employee Get(int id)
Let say I have two methods in MVC 4 Web API controller: public IQueryable<A>
I'm searching for a feature to enable loggin/tracing in ASP.NET MVC 4 Web Api.

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.