How can API return customised names?
For example:
<UserInfo>
<name>aaaaaa</name>
<endpoints>
<int>1</int>
<int>2</int>
</endpoints>
</UserInfo>
is generated from code
public class UserInfo
{
public string name;
public int[] endpoints;
}
I'd like to return this:
<User name="aaaaaa">
<endpoints>
<endpoint>1</endpoint>
<endpoint>2</endpoint>
</endpoints>
</User>
How can I
- Rename UserInfo to User
- Define name as attribute
- Rename fields in endpoints array to
endpoint?
I've tried using [DataContract] and [DataMember], but nothing changed.
EDIT: Method I use to get output:
// GET api/info
[HttpGet("info")]
public IActionResult GetInfo([FromHeader] string auth)
{
if (HasAccess(auth, Endpoints.Info))
{
return new ObjectResult(Database.GetInfoAboutUser(auth));
}
else
{
return Unauthorized();
}
}
... <name>aaaa</name>this<User name="aaaaa">...</User>. 3. means, that items in the array are namedintnow, I want to change their name.