Object Keys
Get keys from json object (assumes all keys are alike for each entry in the array of objects).
by dshilkret
HTML
<script src=" https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
// This is a shortened version of what is returned from the 'ajax' request we send to the server. Remember, the
// returned value is a "string", not an object yet.
var data = var allData = {
"d": {
"query": {
"__metadata": {
"type": "Microsoft.Office.Server.Search.REST.SearchResult"
},
"ElapsedTime": 46,
"PrimaryQueryResult": {
"__metadata": {
"type": "Microsoft.Office.Server.Search.REST.QueryResult"
},
"CustomResults": {
"__metadata": {
"type": "Collection(Microsoft.Office.Server.Search.REST.CustomResult)"
},
"results": []
},
"QueryId": "ca88cf5e-41ab-49dc-8c43-f72aa31327d7",
"QueryRuleId": "00000000-0000-0000-0000-000000000000",
"RefinementResults": null,
"RelevantResults": {
"__metadata": {
"type": "Microsoft.Office.Server.Search.REST.RelevantResults"
},
"GroupTemplateId": null,
"ItemTemplateId": null,
"Properties": {
"results": [
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "GenerationId",
"Value": "9223372036854775806",
"ValueType": "Edm.Int64"
},
{
"__metadata": {
"type": "SP.KeyValue"
},
"Key": "ExecutionTimeMs",
"Value": "15",
...