I am new to Angular2 and using http service to get data from asp.net mvc webapi.
API returns data which is in format shown below
RequestResponse{
public string Message {get;set;}
public int Status {get;set;}
}
Http get request gets data and is fed to map
function from Rxjs
map(result => result.json())
which will convert result into format as shown below
{
message : 'success!',
status : 1
}
As you can see, output property names have lost case sensitivity.
Have read from other SO questions that we have to write our own mapper function to preserve case sensitivity.
My doubt is, is it possible to configure mapper function from Rxjs
to preserve case sensitivity? or should we write our own mapper function?
EDIT: It seems that the issue is from .json()
(?) Why .json()
transforms property names into lowercase?
EDIT: Solution: Thanks @Sergey for the clue. The issue is from .Net Core which was by default converting property names to camelCase. If anybody searcing for the solution, please visit Github page.
Map is a simple function that allows you to transform your data. It fits ideally for your needs: