Reputation: 223
My JSON result is like this:
{
"success": true,
"result": {
"name": "rocky",
"age": 10,
},
"error": null,
"unAuthorizedRequest": false
}
I want to delete ( "success": true,)
. I also want to change "result"
to some other name.
How do I do this in ASP.NET MVC and JavaScript?
Upvotes: 1
Views: 223
Reputation: 13003
This JSON object should be a result of an JSON serialization that your application is made to one of your models (class) when it return a response.
Look for the model that is being serialized and modify it as you wish.
UPDATE:
in order to omit specific property in the serialization, use the JsonIgnore
attribute, for example:
[JsonIgnore]
public bool Success{ get; set; }
Upvotes: 1
Reputation: 1410
You can write a model class for the response, and if you want to give other name to some of the properties like this
[DataMember(Name="othername")]
public string NameToChange { get; set; }
Upvotes: 0