When I serialize an ASP.NET MVC form, I get this:
{
DestinationId: "e96dd00a-b042-41f7-bd59-f369904737b6",
...
}
But I want this, so that it's consistent with JS coding conventions:
{
destinationId: "e96dd00a-b042-41f7-bd59-f369904737b6",
...
}
How do I take an object and lower-case the first character of each property?
Simple way is make iteration over your object:
var newObj = {};
for (var p in o) {
newObj[p.substring(0,1).toLowerCase()+p.substring(1)] = o[p];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With