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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:32:48+00:00 2026-06-14T04:32:48+00:00

I have a Web API project with models that look like this: public class

  • 0

I have a Web API project with models that look like this:

public class Account{

string FirstName{get;set;}
string LastName{get;set;}
}

I would like the JSON response to use a different format and casing for the properties, like this:

first_name
last_name

Is there a way to perform this globally through some sort of json formatter, or is it best to create separate ViewModel classes with appropriate casing?

  • 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-14T04:32:50+00:00Added an answer on June 14, 2026 at 4:32 am

    You should create separate viewmodel classes for a number of reasons.

    It is best to use separate viewmodel classes so that you do not overexpose your model. In the case where you use an entity class with 10 fields as a view model, and you only want to expose 5 of them, a malicious user may post the extra data with a querystring and the automatic bind may fuse that in without you realizing it.

    In your example case, you may want to use entirely different names for the fields. This is a perfect candidate for making a custom viewmodel for your entity class.

    Separating these concerns will help your application be more re-usable in the future, and easier to test / debug in the present. If you find yourself in the situation where there are too many view models, consider factoring out these different controllers, views, and models, into separate areas ( blog on areas ).

    As a side note, if you want to format the JSON it may be easier to do it after the fact in javascript rather than before hand because usually editing the JSON serializer class is a large endeavor. You could write a script which went through and automatically converted camel case to _ separated lower case. A downside to doing that would be that it could have unintended affects in the future if you did not expect the functionality to perform like that.

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

Sidebar

Related Questions

I have an ASP MVC Web Api project that outputs json using json.net. I
In my Web Api project I have a Get method which returns data from
This is a very simple Web API project. I have a data model, generated
I have trying to learn MVC4 Web API. I am running my project from
My project consist of: MVC, WEB API solution. I have generated an ADO.NET entity
I have the following action in my ASP.NET Web API: public IEnumerable<Car> carssOfUser(int id,
Let say I have two methods in MVC 4 Web API controller: public IQueryable<A>
I am starting to use MVC4 Web API project, I have controller with multiple
I have multiple projects that need to pass user login information to common-api project
I have a web project with two models - IndicatorModel and GranteeModel . I

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.