Map entity to JSON using JavaScriptSerializer

前端 未结 2 557
离开以前
离开以前 2020-12-19 04:11

My entities are like this:

class Address
{
     public string Number { get; set; }
     public string Street { get; set; }
     public string City { get; set         


        
2条回答
  •  轮回少年
    2020-12-19 04:40

    You can serialize an anonymous type with JavaScriptSerializer, so you might try projecting your object into the shape you want to serialize:

    person.Select(s => new { PER_NAME = s.Name, PER_AGE = s.Age });
    

提交回复
热议问题