javascript - Turn dictionary into csv - Stack Overflow

var dict = {'Type1':'.typ1','Type2':'.typ2','Type3':&

var dict = {
  'Type1':'.typ1',
  'Type2':'.typ2',
  'Type3':'.typ3'
}

Any chance there's a concise one-liner to produce CSV like following:

".typ1,.typ2,.typ3"
var dict = {
  'Type1':'.typ1',
  'Type2':'.typ2',
  'Type3':'.typ3'
}

Any chance there's a concise one-liner to produce CSV like following:

".typ1,.typ2,.typ3"
Share Improve this question edited Nov 14, 2014 at 21:34 Pointy 414k62 gold badges595 silver badges629 bronze badges asked Nov 14, 2014 at 20:46 RodRod 15.5k35 gold badges134 silver badges264 bronze badges 1
  • 5 Sure: Object.keys(dict).map(function(k){return dict[k];}).join(',');. You're wele. – Felix Kling Commented Nov 14, 2014 at 20:47
Add a ment  | 

2 Answers 2

Reset to default 4
Object.keys(dict).map(function(k){
    return dict[k];
}).join(',');

jQuery solution :

var str = $.map(dict, function(x){return x}).join();

DEMO

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744750165a4591546.html

相关推荐

  • javascript - Turn dictionary into csv - Stack Overflow

    var dict = {'Type1':'.typ1','Type2':'.typ2','Type3':&

    6小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信