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

后端 未结 13 1836
小蘑菇
小蘑菇 2020-12-05 01:21

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

var a = {
    name : \"Foo\",
          


        
13条回答
  •  一个人的身影
    2020-12-05 01:54

    No there is no function in either library that explicitly renames keys. Your method is also the fastest (see jsperf tests.) Your best bet, if possible, is to refactor either the client side or server side code so the objects are the same.

提交回复
热议问题