Skip to content
Advertisement

Is there any way to rename js object keys using underscore.js

I need to convert a js object to another object for passing onto a server post where the names of the keys differ for example

JavaScript

needs to turn into

JavaScript

where I have lookup obj available for mapping all the keys

JavaScript

Is there a function available in underscore.js or jQuery that I can use that does this functionality?

thanks

Advertisement

Answer

As far as I know there is no function built into either of these two libraries. You can make your own fairly easily, though: http://jsfiddle.net/T9Lnr/1/.

JavaScript
Advertisement