JSFiddle - React, Tailwind, and code Playground

by mavdhana

JavaScript

var testjson = {
	"Mytest": [{
		"Testing": {
			"static": {
				"name": "first name"

			},
			"key1": "key1 val",
			"key2": 10

		}
	}, {
		"Testing": {
			"static": {
				"name": "second name"
			},
			"key3": 20,
			"key4": true


		}
	}, {
		"Testing": {
			"static": {
				"name": "third name"
			},
			"key5": "key5 val"

		}
	}]
};

//in coffeescript: @itemNames = (item for item of @mydata).sort (a,b) -> a>b  

var mydata = testjson.Mytest;
var item;

this.itemNames = ((function() {
  var results;
  results = [];
  for (item in mydata) {
    results.push(item);
  }
  return results;
}).call(this)).sort(function(a, b) {
  return a > b;
});

console.log(mydata);//[Object, Object, Object] 
console.log(this.itemNames);//gives: ["0", "1", "2"], but I need like: ["first name", "second name", "third name"], how can I get it ?

//console.log(testjson.Mytest[0]);
//console.log(JSON.stringify(testjson));//full json: testjson 
//console.log(testjson.Mytest[0].Testing.static.name);//gives: first name