JSFiddle - React, Tailwind, and code Playground

by xiao fosong

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json2/20150503/json2.min.js"></script>

JavaScript

var data='{"0":{"name":1,"value":"1"},"1":{"name":2,"value":"2"},"2":{"name":3,"value":"3"},"6":{"name":4,"value":"4"}}';
    
var result  = JSON.parse(data);
var typeofResult = typeof result;

var method1_result = method2_result = [];
if(typeofResult == 'object'){
  //first 开始使用的方法
	method1_result = $.map(result, function(el,index) { return el; });
  //目前项目使用的方法
  for(var index in result){
    if (result.hasOwnProperty(index)) {
      method2_result[index] = result[index];
    }
  }
}
console.log(method1_result);
console.log(method2_result);