Using .
you can get the current element. There is no possibility using JsonPath to extract key names. Hence, you can do this in JavaScript by using for
and grabbing the key name.
The following HTML shows a complete example:
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="jsonpath.js"></script>
</head>
<body>
<h1 id="h1"></h1>
<script type="text/javascript">
var o = {"q0":{"query":"WilLIAM","limit":3}};
var key;
for(var i in jsonPath(o, ".")[0]) key = i;
document.getElementById("h1").appendChild(document.createTextNode(
key
));
</script>
</body>
</html>
Here is a Plunkr: http://plnkr.co/edit/CaZD1lVhr1E2S8VN5vnP