Why are public properties being serialized w/ an underscore in MVC4?

abbi

New Member
In the following class\[code\]using System;namespace Beverati.Repository.ViewModel{[Serializable]public class CollectionItem : EditableEntityBase{public CollectionItem() {}private int? _quantity;private string _retailValue;private string _currencyName;public int? quantity{ get { return this._quantity ?? NULL_INTEGER; } set { this._quantity = value; }}public string retailValue{ get { return this._retailValue ?? String.Empty; } set { this._retailValue = http://stackoverflow.com/questions/14062364/value; }}public string currencyName{ get { return this._currencyName ?? String.Empty; } set { this._currencyName = value; }}}}\[/code\]returned in this controller action\[code\]public IEnumerable<Repository.ViewModel.CollectionItem> GetAll()\[/code\]produces this JSON output with MVC2 the JSON output like this\[code\]{ quantity:2 retailValue: 50.00 currencyName: USD}\[/code\]However, when I installed MVC4 the JSON returned looks like this\[code\]{ _quantity:2 _retailValue: 50.00 _currencyName: USD}\[/code\]All the property names have an underscore prefix. Why is the underscore being used and what should be done to have the public property names returned in the JSON?
 
Back
Top