I have a JSON
var x = {
"dialog_trunk_1":{
"message": "This is just a JSON Test"
},
"dialog_trunk_2":{
"message": "and a test of the second message"
},
"dialog_trunk_3":
{
"message": "This is a test of a bit longer text. Hopefully this will at the very least create 3 lines and trigger us to go on to another box. So we can test multi-box functionality, too."
}
}
Where I need to get all the keys in the order which they are defined. I have seen the Object.Entries ECMA6. Not sure how to use.
I have tried with simple for
keys = []
for(var key in x)
{
keys.push(key)
}
But this order is unexpected.
The expected results must be
keys = ["dialog_trunk_1","dialog_trunk_2","dialog_trunk_3"]