JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/douglascrockford/JSON-js/master/json2.js"></script>
JavaScript
var jsonData, obj, lines, keys, keyICareAbout, info, firstline;
// Note: json2.js is included from: https://github.com/douglascrockford/JSON-js
// If you require support from older browsers, do this:
if(!Object.keys) Object.keys = function(o){
if (o !== Object(o))
throw new TypeError('Object.keys called on non-object');
var ret=[],p;
for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
return ret;
}
// The slashes escape the newlines, ignore them
jsonData = '{ \
"Files": { \
"Lines": { \
"198": { \
"firstline": "sometext" \
} \
} \
} \
}';
obj = JSON.parse(jsonData);
lines = obj.Files.Lines;
keys = Object.keys(lines);
keyICareAbout = keys[0];
info = lines[keyICareAbout];
firstline = info.firstline;
alert("My key: " + keyICareAbout + "\n" +
"My info: " + JSON.stringify(info) + "\n" +
"firstline: " + firstline);