mercredi 2 novembre 2016

Google Postman: How to get properties of an Array

I've got a problem by checking this json properties. I want to test, if the formName is "TestForm_WF1", but I dont know how to write the test to check the properties of this strange named array:

{
  "#!#": [
    {
      "_type": "wfdocument",
      "formName": "TestForm_WF1",

normally I got some Output like

[
  {
    "_type": "application",
    ...

which I could test with the following forEach-function:

var response = JSON.parse(responseBody);
response.forEach( function(entry) {
   test["foo"] = entry._type === "application";
   ... 
});

other way round was that properties have thier own properties and could be tested like:

Output:

{
  "license": {
    "_type": "license",
    ...

Testcase:

var jsonData = JSON.parse(responseBody);
tests["bar"] = jsonData.license._type === "license";

Aucun commentaire:

Enregistrer un commentaire