How get only some data from json

Hi, I get a json file from get method like this:

$scope.chiamataUno = function() {
var authdata = Base64.encode(“xxx” + “:” + “xxxx”);
$http.defaults.headers.common[“Authorization”] = "Basic " + authdata;
$http.get(‘http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/P8BPMREST/p8/bpm/v1/queues/DV_ResponsabileBSDL/workbaskets/Responsabile BSDL/queueelements/?cp=DCMSVS_CONN1’).success(function(response) {
$scope.risposta = response;
$rootScope.responseJSON = JSON.stringify($scope.risposta);
console.log("json " + JSON.stringify($scope.risposta));
})
.error(function(response) {
alert(“ERROR”);
});
}
and it is a very huge json with many objects with the same field. How can I analyze the json and take just the value that i want??

Thanks in advance.

Hello,

Can you share the design of your json string? what objects do you have? Since it is a JSON object, you should be able to navigate between the objects and get the one you want.

{
“stepProcessors”: {
“183”: {
“id”: 183,
“height”: 600,
“processorType”: 8,
“locations”: {
“11”: “desktop=icm&feature=Cases&tos=CM_DCMSVS_TGT_OBJ&solution=DV&pageReferenceName=DettaglidellavoroBSDLOdA”
},
“applicationName”: “”,
“width”: 800,
“name”: “DV_Dettagli del lavoro BSDL OdA”,
“appType”: 32
},
“184”: {
“id”: 184,
“height”: 600,
“processorType”: 8,
“locations”: {
“11”: “desktop=icm&feature=Cases&tos=CM_DCMSVS_TGT_OBJ&solution=DV&pageReferenceName=LavoroBSDL_ApprovaRifutaOdA”
},
“applicationName”: “”,
“width”: 800,
“name”: “DV_Dettagli del lavoro BSDL approvarifuta OdA”,
“appType”: 32
}
},

"queueElements": 

[{
    "canReassign": true,
    "ETag": "27.0",
    "lockedBy": "",
    "stepDeadlineStatus": 0,
    "columns": {
        "DV_NAMECL_POS_ODA": "Tieleman Transport BV",
        "DV_MATNR_TXZ01_POS_ODA": "445811 - EUROPRENE SBR 1500 GUC BOX 1110 P150 - 1",
        "F_StepName": "Item details",
        "DV_Caseidentifier_for_eni_OdA": null,
        "DV_MENGE_MEINS_POS_ODA": "20.000 - KG",
        "DV_PEINH_POS": "1000 - KG",
        "DV_NETPR_WAERS_POS_ODA": "1.000 - EUR",
        "DV_EINDT_ODA": "2015\/11\/28",
        "DV_EBELP_ODA": "00010"
    },
    "caseTaskId": "{28BE9F56-A7D7-4CA5-B777-A51FF3847236}",
    "stepElement": "queues\/DV_ResponsabileBSDL\/stepelements\/93DF1BFA1C39A145A4B089BEA6195A08",
    "milestones": "queues\/DV_ResponsabileBSDL\/stepelements\/93DF1BFA1C39A145A4B089BEA6195A08\/milestones",
    "boundUserName": "",
    "stepProcessorId": 183,
    "lockedById": 0,
    "queueName": "DV_ResponsabileBSDL",
    "workObjectNumber": "93DF1BFA1C39A145A4B089BEA6195A08",
    "caseFolderId": "{2854EE70-146A-4618-826C-BA33FC807A25}",
    "stepName": "Item details"
}, {
    "canReassign": true,
    "ETag": "35.0",
    "lockedBy": "",
    "stepDeadlineStatus": 0,
    "columns": {
        "DV_NAMECL_POS_ODA": "Tieleman Transport BV",
        "DV_MATNR_TXZ01_POS_ODA": "445811 - EUROPRENE SBR 1500 GUC BOX 1110 P150 - 1",
        "F_StepName": "Item details",
        "DV_Caseidentifier_for_eni_OdA": null,
        "DV_MENGE_MEINS_POS_ODA": "20.000 - KG",
        "DV_PEINH_POS": "1000 - KG",
        "DV_NETPR_WAERS_POS_ODA": "1.000 - EUR",
        "DV_EINDT_ODA": "2015\/11\/28",
        "DV_EBELP_ODA": "00010"
    },
    "caseTaskId": "{4D6AC14B-524F-49DE-8AE9-9DB81AC9EDB0}",
    "stepElement": "queues\/DV_ResponsabileBSDL\/stepelements\/45E02717DC9C0D4D88D5C7989E15DEEE",
    "milestones": "queues\/DV_ResponsabileBSDL\/stepelements\/45E02717DC9C0D4D88D5C7989E15DEEE\/milestones",
    "boundUserName": "",
    "stepProcessorId": 183,
    "lockedById": 0,
    "queueName": "DV_ResponsabileBSDL",
    "workObjectNumber": "45E02717DC9C0D4D88D5C7989E15DEEE",
    "caseFolderId": "{6FC87589-6D4D-44BA-93BA-17684FC67431}",
    "stepName": "Item details"
}, {
    "canReassign": true,
    "ETag": "36.0",
    "lockedBy": "",
    "stepDeadlineStatus": 0,
    "columns": {
        "DV_NAMECL_POS_ODA": "Tieleman Transport BV",
        "DV_MATNR_TXZ01_POS_ODA": "445811 - EUROPRENE SBR 1500 GUC BOX 1110 P150 - 1",
        "F_StepName": "Item details",
        "DV_Caseidentifier_for_eni_OdA": null,
        "DV_MENGE_MEINS_POS_ODA": "350.000 - KG",
        "DV_PEINH_POS": "1000 - KG",
        "DV_NETPR_WAERS_POS_ODA": "1.000 - EUR",
        "DV_EINDT_ODA": "2015\/11\/09",
        "DV_EBELP_ODA": "00020"
    },
    "caseTaskId": "{4A07625D-CCF3-494B-ABA3-73A6C43846E9}",
    "stepElement": "queues\/DV_ResponsabileBSDL\/stepelements\/D53D0B2DA882D1469AECC8637A8DC38E",
    "milestones": "queues\/DV_ResponsabileBSDL\/stepelements\/D53D0B2DA882D1469AECC8637A8DC38E\/milestones",
    "boundUserName": "",
    "stepProcessorId": 183,
    "lockedById": 0,
    "queueName": "DV_ResponsabileBSDL",
    "workObjectNumber": "D53D0B2DA882D1469AECC8637A8DC38E",
    "caseFolderId": "{6FC87589-6D4D-44BA-93BA-17684FC67431}",
    "stepName": "Item details"
}, {
    "canReassign": true,
    "ETag": "81.0",
    "lockedBy": "",
    "stepDeadlineStatus": 0,
    "columns": {
        "DV_NAMECL_POS_ODA": "?",
        "DV_MATNR_TXZ01_POS_ODA": "? - ?",
        "F_StepName": "Item details",
        "DV_Caseidentifier_for_eni_OdA": "Case_Po_000000590001",
        "DV_MENGE_MEINS_POS_ODA": "? - ?",
        "DV_PEINH_POS": null,
        "DV_NETPR_WAERS_POS_ODA": "? - ?",
        "DV_EINDT_ODA": "?",
        "DV_EBELP_ODA": "?"
    },
    "caseTaskId": "{981E2AA7-F8D7-4C10-9452-6E3673CECAF4}",
    "stepElement": "queues\/DV_ResponsabileBSDL\/stepelements\/1389E32AF3F08E4CB173E1DF16DE65C4",
    "milestones": "queues\/DV_ResponsabileBSDL\/stepelements\/1389E32AF3F08E4CB173E1DF16DE65C4\/milestones",
    "boundUserName": "",
    "stepProcessorId": 183,
    "lockedById": 0,
    "queueName": "DV_ResponsabileBSDL",
    "workObjectNumber": "1389E32AF3F08E4CB173E1DF16DE65C4",
    "caseFolderId": "{46322D25-21C7-4723-BCA0-7ECF809E2267}",
    "stepName": "Item details"
},

and so on in this way…i need to put some of this data in a table, and show in a list.

image

Which data do you want to show in a list?

good question…i need some fields like "stepName and 90% of the fields in columns…for each object

Try building a new object and insert your items into that object. I am giving you an example and I believe you can do the rest;

var newArray = []; for(var i=0;i<response.QueueElements.length;i++) { var newObject = {stepName:response.QueueElements[i].stepName,columns:response.QueueElements[i].columns}; newArray.push(newObject); }

1 Like

thank you so much…i’ll try now! very helpful

i’ll try this before but doesn’t work

$scope.risposta = [];
$scope.chiamataUno = function() {
var authdata = Base64.encode(“DEMVSINT_ADMIN” + “:” + “Password01”);
$http.defaults.headers.common[“Authorization”] = "Basic " + authdata;
$http.get(‘http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/P8BPMREST/p8/bpm/v1/queues/DV_ResponsabileBSDL/workbaskets/Responsabile BSDL/queueelements/?cp=DCMSVS_CONN1’).success(function(response) {
console.log(response);
var risposta = [];
angular.forEach(response.queueElements, function(child){
console.log(child.queueElements);
risposta.push(child.queueElements);
});
})
.error(function(response) {
alert(“ERROR”);
});
}

In your angular.forEach function, you are looping through your queueelements, so you are trying to access queueelements.queueelemtns which does not exists. log your child and you will understand.

thank you so much for the explain…now the vpn is down and i can’t try, but you right.

Hi…i’ll try,
var newArray = [];
for(var i=0;i<response.queueElements.length;i++)
{
var newObject = {stepName:response.queueElements[i].stepName,columns:response.queueElements[i].columns};
newArray.push(newObject);
console.log("nuovo oggetto " + newObject);
console.log("nuovo array " + newArray);
}

but the result is comething like that for all objects

nuovo oggetto [object Object]

nuovo array [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

if i use this
var risposta = [];
angular.forEach(response.queueElements, function(child){
console.log(child.queueElements);

    console.log(child);
    risposta.push(child.queueElements);
  });

the result is this

Object {canReassign: true, ETag: “27.0”, lockedBy: “”, stepDeadlineStatus: 0, columns: Object…}
ETag: "27.0"
boundUserName: ""
canReassign: true
caseFolderId: "{2854EE70-146A-4618-826C-BA33FC807A25}"
caseTaskId: "{28BE9F56-A7D7-4CA5-B777-A51FF3847236}"
columns: Object
DV_Caseidentifier_for_eni_OdA: null
DV_EBELP_ODA: "00010"
DV_EINDT_ODA: "2015/11/28"
DV_MATNR_TXZ01_POS_ODA: "445811 - EUROPRENE SBR 1500 GUC BOX 1110 P150 - 1"
DV_MENGE_MEINS_POS_ODA: "20.000 - KG"
DV_NAMECL_POS_ODA: "Tieleman Transport BV"
DV_NETPR_WAERS_POS_ODA: "1.000 - EUR"
DV_PEINH_POS: "1000 - KG"
F_StepName: "Item details"
proto: Object
lockedBy: ""
lockedById: 0
milestones: "queues/DV_ResponsabileBSDL/stepelements/93DF1BFA1C39A145A4B089BEA6195A08/milestones"
queueName: "DV_ResponsabileBSDL"
stepDeadlineStatus: 0
stepElement: "queues/DV_ResponsabileBSDL/stepelements/93DF1BFA1C39A145A4B089BEA6195A08"
stepName: "Item details"
stepProcessorId: 183
workObjectNumber: "93DF1BFA1C39A145A4B089BEA6195A08"
proto: Object

undefined
Object {canReassign: true, ETag: “35.0”, lockedBy: “”, stepDeadlineStatus: 0, columns: Object…}

undefined
Object {canReassign: true, ETag: “36.0”, lockedBy: “”, stepDeadlineStatus: 0, columns: Object…}

undefined
Object {canReassign: true, ETag: “81.0”, lockedBy: “”, stepDeadlineStatus: 0, columns: Object…}

undefined
Object {canReassign: true, ETag: “173.0”, lockedBy: “”, stepDeadlineStatus: 0, columns: Object…}

undefined
Object {canReassign: true, ETag: “174.0”, lockedBy: “”, stepDeadlineStatus: 0, columns: Object…}

undefined

for all objects

Because child.queueElements is undefined.

whit this code (thank you emrebfy) i get the data, but how i can put this data on a table?

$scope.chiamataUno = function() {
var authdata = Base64.encode(“DEMVSINT_ADMIN” + “:” + “Password01”);
$http.defaults.headers.common[“Authorization”] = "Basic " + authdata;
$http.get(‘http://demvsint-as1-sd.services.eni.intranet:8001/CaseManager/P8BPMREST/p8/bpm/v1/queues/DV_ResponsabileBSDL/workbaskets/Responsabile BSDL/queueelements/?cp=DCMSVS_CONN1’).success(function(response) {
console.log(response);

    var newArray = [];
    for(var i=0;i<response.queueElements.length;i++)
    {
    var newObject = {
      
      elementi:response.queueElements[i],
      caseFolderId:response.queueElements[i].caseFolderId,
      caseTaskId:response.queueElements[i].caseTaskId,
      stepName:response.queueElements[i].stepName,
      columns:response.queueElements[i].columns
    };
    newArray.push(newObject);
    console.log("INIZIO OGGETTO");
  console.log("Queue Elements oggetto caseFolderId " + newObject.caseFolderId);
  console.log("Queue Elements oggetto caseTaskId " + newObject.caseTaskId);
  console.log("Queue Elements oggetto stepName " + newObject.stepName);

    console.log("columns oggetto DV_Caseidentifier_for_eni_OdA " + newObject.columns.DV_Caseidentifier_for_eni_OdA);
    console.log("columns oggetto DV_EBELP_ODA " + newObject.columns.DV_EBELP_ODA);
    console.log("columns oggetto DV_EINDT_ODA " + newObject.columns.DV_EINDT_ODA);
    console.log("columns oggetto DV_MATNR_TXZ01_POS_ODA " + newObject.columns.DV_MATNR_TXZ01_POS_ODA);
    console.log("columns oggetto DV_NAMECL_POS_ODA " + newObject.columns.DV_NAMECL_POS_ODA);
    console.log("columns oggetto DV_NETPR_WAERS_POS_ODA " + newObject.columns.DV_NETPR_WAERS_POS_ODA);
    console.log("columns oggetto DV_PEINH_POS " + newObject.columns.DV_PEINH_POS);
    console.log("columns oggetto DV_MENGE_MEINS_POS_ODA " + newObject.columns.DV_MENGE_MEINS_POS_ODA);
    console.log("FINE OGGETTO");

    $scope.newObject = newObject;
    $scope.newArray = newArray;
    
    
    }
        })
        .error(function(response) {
            alert("ERROR");
        });