just started with json. I have something similar to this data (this data is called Data0012.json and I cant edit it or change the -162.65 to another thing ... also ... that first data, changes, so I cant call it):
{
"-162.65": {
"Player": "DntFuckwithMeMTFrs",
"Hands": "44",
"(BTN) PFR (2-2,25) (16+)": "13",
"!!!0 All-In Equity Adjusted BB/100": "-162.65",
"BH_MTT_3Bet (BB vs BU open)": "50"
},
"-162.27": {
"Player": "paramasivum",
"Hands": "40",
"(BTN) PFR (2-2,25) (16+)": "9",
"!!!0 All-In Equity Adjusted BB/100": "-162.27",
"BH_MTT_3Bet (BB vs BU open)": "67"
},
"-157.32": {
"Player": "Fairline69",
"Hands": "49",
"(BTN) PFR (2-2,25) (16+)": "25",
"!!!0 All-In Equity Adjusted BB/100": "-157.32",
"BH_MTT_3Bet (BB vs BU open)": "17"
},
}
I need to extract the keys from this data, without knowing this data (as if I havent seen the json), and without changing the json file... it comes as it's shown above.
I have to do this with a js. The keys will change with new json's, and I need to repeat this process and extract the keys to use them in the next script. How do I do this correctly.
I've tried with this:
<script src="./Data0012.json">
var s = require('./Data0012.json');
var data = JSON.parse(s);
for (var key in data) {
var value = data[key];
}
console.log(key);
</script>
but the console gives me an error with data:
Uncaught SyntaxError: Unexpected token ':' (at Data0012.json:2:14) attribute
what can I do to solve this. Help please.(dont give me negative points) Edited; Input: Data0012.json output wanted: Data0012.json's key's