Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "ChangeCollectionList": [
- {
- "AssetID": "Server123",
- "ChangeDateTime": "2014-07-25T16:14:32.6575954-07:00",
- "TriggerID": "Deployement_07_25_2014"
- },
- {
- "AssetID": "Server123",
- "ChangeDateTime": "2014-07-25T16:14:32.6575954-07:00",
- "TriggerID": "Patch_07_26_2014"
- },
- {
- "AssetID": "ServerABC",
- "ChangeDateTime": "2014-07-25T16:14:32.6575954-07:00",
- "TriggerID": "Deployement_07_25_2014"
- }
- ],
- "TriggerList": [
- {
- "TriggerID": "Deployement_07_25_2014",
- "PropertyChangeList": [
- {
- "PropertyID": "16.00.12.2345",
- "PropertyType": "Build",
- "ChangeType": "Modified",
- "ChangedDateTime": "2014-07-25T00:00:00",
- "HasNestedChanges": true
- },
- {
- "PropertyID": "\exc\cafe\cafeproxy.cs",
- "PropertyType": "SourceCode",
- "ChangeType": "Modified",
- "ChangedDateTime": "2014-07-25T00:00:00",
- "HasNestedChanges": false
- },
- {
- "PropertyID": "\exc\momt\rpcproxy.cs",
- "PropertyType": "SourceCode",
- "ChangeType": "Modified",
- "ChangedDateTime": "2014-07-25T00:00:00",
- "HasNestedChanges": false
- }
- ]
- },....
- $.getJSON("jsonSample.json", function (obj) {
- var dictionary = {};
- var local_cell_ids = [];
- $.each(obj.ChangeCollectionList, function (key, value) {
- if (local_cell_ids.length == 0) {
- local_cell_ids.push(value.AssetID);
- insertIntoDic(value.AssetID, value.TriggerID);
- }
- else {
- for (var i = 0; i < local_cell_ids.length; i++) {
- if (local_cell_ids[i] == value.AssetID) {
- insertIntoDic(value.AssetID, value.TriggerID);
- break;
- }
- if (i = local_cell_ids.length) {
- local_cell_ids.push(value.AssetID);
- insertIntoDic(value.AssetID, value.TriggerID);
- }
- }
- }
- });
- function insertIntoDic(key, value) {
- // If key is not initialized or some bad structure
- if (!dictionary[key] || !(dictionary[key] instanceof Array)) {
- dictionary[key] = [];
- }
- // All arguments, exept first push as valuses to the dictonary
- dictionary[key] = dictionary[key].concat(Array.prototype.slice.call(arguments, 1));
- //alert(dictionary[key]);
- }
- for (var key in dictionary) {enter code here
- $("#accordion").accordion();
- $("<h3>" + key + "</h3>").appendTo("#accordion");
- $("<div> <p> " + dictionary[key] + "<p></div><").appendTo("#accordion");
- // $("<div> <p> " + dictionary[key] + "<p></div><").appendTo("#accordion");
- $("#accordion").accordion("refresh");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement