JSON Parse to get objects within array












1















I've never done anything like this before and are struggling to get this working, I have tried different code samples online but to no joy.



I want to return the displayName from the 5 objects in the below array.



array example



first



I'm restricted to only use ES5.



I tried the below but was only getting the first object when printing rather than all 5.






for (var i = 0; i < parsed.value.length; i++) {
var counter = parsed.value[i].displayName;
}





Any tips/points? As you can tell I'm new to this!



Thanks.










share|improve this question

























  • My guess is you were doing something with counter after loop finished. You didn't really show much code in that loop to know how you use that variable

    – charlietfl
    Nov 24 '18 at 2:58













  • I recommend you do not use images for this type of questions it is easier to collaborate if you provide a code to copy and start working. It also allows you to avoid hiding sensitive information. These, among other advantages

    – user615274
    Nov 24 '18 at 3:15
















1















I've never done anything like this before and are struggling to get this working, I have tried different code samples online but to no joy.



I want to return the displayName from the 5 objects in the below array.



array example



first



I'm restricted to only use ES5.



I tried the below but was only getting the first object when printing rather than all 5.






for (var i = 0; i < parsed.value.length; i++) {
var counter = parsed.value[i].displayName;
}





Any tips/points? As you can tell I'm new to this!



Thanks.










share|improve this question

























  • My guess is you were doing something with counter after loop finished. You didn't really show much code in that loop to know how you use that variable

    – charlietfl
    Nov 24 '18 at 2:58













  • I recommend you do not use images for this type of questions it is easier to collaborate if you provide a code to copy and start working. It also allows you to avoid hiding sensitive information. These, among other advantages

    – user615274
    Nov 24 '18 at 3:15














1












1








1


1






I've never done anything like this before and are struggling to get this working, I have tried different code samples online but to no joy.



I want to return the displayName from the 5 objects in the below array.



array example



first



I'm restricted to only use ES5.



I tried the below but was only getting the first object when printing rather than all 5.






for (var i = 0; i < parsed.value.length; i++) {
var counter = parsed.value[i].displayName;
}





Any tips/points? As you can tell I'm new to this!



Thanks.










share|improve this question
















I've never done anything like this before and are struggling to get this working, I have tried different code samples online but to no joy.



I want to return the displayName from the 5 objects in the below array.



array example



first



I'm restricted to only use ES5.



I tried the below but was only getting the first object when printing rather than all 5.






for (var i = 0; i < parsed.value.length; i++) {
var counter = parsed.value[i].displayName;
}





Any tips/points? As you can tell I'm new to this!



Thanks.






for (var i = 0; i < parsed.value.length; i++) {
var counter = parsed.value[i].displayName;
}





for (var i = 0; i < parsed.value.length; i++) {
var counter = parsed.value[i].displayName;
}






javascript json api parsing ecmascript-5






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 4:23









hygull

3,43011229




3,43011229










asked Nov 24 '18 at 1:45









user1780144user1780144

223




223













  • My guess is you were doing something with counter after loop finished. You didn't really show much code in that loop to know how you use that variable

    – charlietfl
    Nov 24 '18 at 2:58













  • I recommend you do not use images for this type of questions it is easier to collaborate if you provide a code to copy and start working. It also allows you to avoid hiding sensitive information. These, among other advantages

    – user615274
    Nov 24 '18 at 3:15



















  • My guess is you were doing something with counter after loop finished. You didn't really show much code in that loop to know how you use that variable

    – charlietfl
    Nov 24 '18 at 2:58













  • I recommend you do not use images for this type of questions it is easier to collaborate if you provide a code to copy and start working. It also allows you to avoid hiding sensitive information. These, among other advantages

    – user615274
    Nov 24 '18 at 3:15

















My guess is you were doing something with counter after loop finished. You didn't really show much code in that loop to know how you use that variable

– charlietfl
Nov 24 '18 at 2:58







My guess is you were doing something with counter after loop finished. You didn't really show much code in that loop to know how you use that variable

– charlietfl
Nov 24 '18 at 2:58















I recommend you do not use images for this type of questions it is easier to collaborate if you provide a code to copy and start working. It also allows you to avoid hiding sensitive information. These, among other advantages

– user615274
Nov 24 '18 at 3:15





I recommend you do not use images for this type of questions it is easier to collaborate if you provide a code to copy and start working. It also allows you to avoid hiding sensitive information. These, among other advantages

– user615274
Nov 24 '18 at 3:15












3 Answers
3






active

oldest

votes


















1














You can also have a look at the below simple examples.




These examples do not include all the fields from your input data but relevant.



I think, it will be helpful.




var parsed = {
value: [
{fullName: "Ken Thompson", displayName: "Ken", age: 55},
{fullName: "Rob Pike", displayName: "Rob", age: 50},
{fullName: "Robert Griesemer", displayName: "RobertGoog", age: 56},
{fullName: "Ander Hezlsberg", displayName: "AndersMicro", age: 58},
{fullName: "Ryan Dahl", displayName: "Ryan08", age: 40}
]
};

// 1st way to get as an array of objects
var dispNames = parsed.value.map(function(o) { return {displayName: o.displayName}});
console.log(dispNames);

/*
[ { displayName: 'Ken' },
{ displayName: 'Rob' },
{ displayName: 'RobertGoog' },
{ displayName: 'AndersMicro' },
{ displayName: 'Ryan08' } ]
*/

// 2nd way to get as a list of displayNames
var dispNames2 = parsed.value.map(function(o) { return o.displayName});
console.log(dispNames2);
/*
[ 'Ken', 'Rob', 'RobertGoog', 'AndersMicro', 'Ryan08' ]
*/

// 3rd way to get as a string with displayNames separated with comma(,)
console. log(dispNames2.join(","));
/*
Ken,Rob,RobertGoog,AndersMicro,Ryan08
*/


If you want to get result as the above 3rd way shows, here is most simple way to get that without using join() method defined on array objects.



console.log("" + dispNames2);
// Ken,Rob,RobertGoog,AndersMicro,Ryan08





share|improve this answer





















  • 1





    This is brilliant, thank you so much! It is exactly what I was looking to achieve. I can see the map function being very useful for me in other cases too.

    – user1780144
    Nov 27 '18 at 18:04











  • You are welcome. Thank you.

    – hygull
    Nov 27 '18 at 19:16



















1














Not sure exactly what you need, but I think it will work :



var names = parsed.value.map(function(v){ return v.displayName });


Now names is an array containing all the displayName values.



If you want objects with just the displayName property, then :



var objects = parsed.value.map(function(v) { 
return {
displayName: v.displayName
};
});


You can check MDN doc for map






share|improve this answer

































    0














    As Johnny5 suggests, the map function is the ideal in this case. Try this approximation where you get an array of objects like the original dataset






    const dataset = [
    {
    classification: null,
    createdDateTime: new Date('2018-03-03'),
    deletedDateTime: null,
    description: 'lorem ipsum',
    displayName: 'John Logan',
    mail: 'john.logan@domain.com',
    }, {
    classification: null,
    createdDateTime: new Date('2018-03-03'),
    deletedDateTime: null,
    description: 'lorem ipsum',
    displayName: 'Ken Master',
    mail: 'ken.master@domain.com',
    }, {
    classification: null,
    createdDateTime: new Date('2018-03-03'),
    deletedDateTime: null,
    description: 'lorem ipsum',
    displayName: 'Samus Aran',
    mail: 'samus.aran@domain.com',
    }, {
    classification: null,
    createdDateTime: new Date('2018-03-03'),
    deletedDateTime: null,
    description: 'lorem ipsum',
    displayName: 'King Dede',
    mail: 'king.dede@domain.com',
    }, {
    classification: null,
    createdDateTime: new Date('2018-03-03'),
    deletedDateTime: null,
    description: 'lorem ipsum',
    displayName: 'Monkey D Luffy',
    mail: 'luffy.monkey@domain.com',
    }
    ];

    const displayNames = dataset.map(toDisplayNameView);

    function toDisplayNameView(data) {
    return {
    displayName: data.displayName
    };
    }

    console.log(displayNames);








    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454500%2fjson-parse-to-get-objects-within-array%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      You can also have a look at the below simple examples.




      These examples do not include all the fields from your input data but relevant.



      I think, it will be helpful.




      var parsed = {
      value: [
      {fullName: "Ken Thompson", displayName: "Ken", age: 55},
      {fullName: "Rob Pike", displayName: "Rob", age: 50},
      {fullName: "Robert Griesemer", displayName: "RobertGoog", age: 56},
      {fullName: "Ander Hezlsberg", displayName: "AndersMicro", age: 58},
      {fullName: "Ryan Dahl", displayName: "Ryan08", age: 40}
      ]
      };

      // 1st way to get as an array of objects
      var dispNames = parsed.value.map(function(o) { return {displayName: o.displayName}});
      console.log(dispNames);

      /*
      [ { displayName: 'Ken' },
      { displayName: 'Rob' },
      { displayName: 'RobertGoog' },
      { displayName: 'AndersMicro' },
      { displayName: 'Ryan08' } ]
      */

      // 2nd way to get as a list of displayNames
      var dispNames2 = parsed.value.map(function(o) { return o.displayName});
      console.log(dispNames2);
      /*
      [ 'Ken', 'Rob', 'RobertGoog', 'AndersMicro', 'Ryan08' ]
      */

      // 3rd way to get as a string with displayNames separated with comma(,)
      console. log(dispNames2.join(","));
      /*
      Ken,Rob,RobertGoog,AndersMicro,Ryan08
      */


      If you want to get result as the above 3rd way shows, here is most simple way to get that without using join() method defined on array objects.



      console.log("" + dispNames2);
      // Ken,Rob,RobertGoog,AndersMicro,Ryan08





      share|improve this answer





















      • 1





        This is brilliant, thank you so much! It is exactly what I was looking to achieve. I can see the map function being very useful for me in other cases too.

        – user1780144
        Nov 27 '18 at 18:04











      • You are welcome. Thank you.

        – hygull
        Nov 27 '18 at 19:16
















      1














      You can also have a look at the below simple examples.




      These examples do not include all the fields from your input data but relevant.



      I think, it will be helpful.




      var parsed = {
      value: [
      {fullName: "Ken Thompson", displayName: "Ken", age: 55},
      {fullName: "Rob Pike", displayName: "Rob", age: 50},
      {fullName: "Robert Griesemer", displayName: "RobertGoog", age: 56},
      {fullName: "Ander Hezlsberg", displayName: "AndersMicro", age: 58},
      {fullName: "Ryan Dahl", displayName: "Ryan08", age: 40}
      ]
      };

      // 1st way to get as an array of objects
      var dispNames = parsed.value.map(function(o) { return {displayName: o.displayName}});
      console.log(dispNames);

      /*
      [ { displayName: 'Ken' },
      { displayName: 'Rob' },
      { displayName: 'RobertGoog' },
      { displayName: 'AndersMicro' },
      { displayName: 'Ryan08' } ]
      */

      // 2nd way to get as a list of displayNames
      var dispNames2 = parsed.value.map(function(o) { return o.displayName});
      console.log(dispNames2);
      /*
      [ 'Ken', 'Rob', 'RobertGoog', 'AndersMicro', 'Ryan08' ]
      */

      // 3rd way to get as a string with displayNames separated with comma(,)
      console. log(dispNames2.join(","));
      /*
      Ken,Rob,RobertGoog,AndersMicro,Ryan08
      */


      If you want to get result as the above 3rd way shows, here is most simple way to get that without using join() method defined on array objects.



      console.log("" + dispNames2);
      // Ken,Rob,RobertGoog,AndersMicro,Ryan08





      share|improve this answer





















      • 1





        This is brilliant, thank you so much! It is exactly what I was looking to achieve. I can see the map function being very useful for me in other cases too.

        – user1780144
        Nov 27 '18 at 18:04











      • You are welcome. Thank you.

        – hygull
        Nov 27 '18 at 19:16














      1












      1








      1







      You can also have a look at the below simple examples.




      These examples do not include all the fields from your input data but relevant.



      I think, it will be helpful.




      var parsed = {
      value: [
      {fullName: "Ken Thompson", displayName: "Ken", age: 55},
      {fullName: "Rob Pike", displayName: "Rob", age: 50},
      {fullName: "Robert Griesemer", displayName: "RobertGoog", age: 56},
      {fullName: "Ander Hezlsberg", displayName: "AndersMicro", age: 58},
      {fullName: "Ryan Dahl", displayName: "Ryan08", age: 40}
      ]
      };

      // 1st way to get as an array of objects
      var dispNames = parsed.value.map(function(o) { return {displayName: o.displayName}});
      console.log(dispNames);

      /*
      [ { displayName: 'Ken' },
      { displayName: 'Rob' },
      { displayName: 'RobertGoog' },
      { displayName: 'AndersMicro' },
      { displayName: 'Ryan08' } ]
      */

      // 2nd way to get as a list of displayNames
      var dispNames2 = parsed.value.map(function(o) { return o.displayName});
      console.log(dispNames2);
      /*
      [ 'Ken', 'Rob', 'RobertGoog', 'AndersMicro', 'Ryan08' ]
      */

      // 3rd way to get as a string with displayNames separated with comma(,)
      console. log(dispNames2.join(","));
      /*
      Ken,Rob,RobertGoog,AndersMicro,Ryan08
      */


      If you want to get result as the above 3rd way shows, here is most simple way to get that without using join() method defined on array objects.



      console.log("" + dispNames2);
      // Ken,Rob,RobertGoog,AndersMicro,Ryan08





      share|improve this answer















      You can also have a look at the below simple examples.




      These examples do not include all the fields from your input data but relevant.



      I think, it will be helpful.




      var parsed = {
      value: [
      {fullName: "Ken Thompson", displayName: "Ken", age: 55},
      {fullName: "Rob Pike", displayName: "Rob", age: 50},
      {fullName: "Robert Griesemer", displayName: "RobertGoog", age: 56},
      {fullName: "Ander Hezlsberg", displayName: "AndersMicro", age: 58},
      {fullName: "Ryan Dahl", displayName: "Ryan08", age: 40}
      ]
      };

      // 1st way to get as an array of objects
      var dispNames = parsed.value.map(function(o) { return {displayName: o.displayName}});
      console.log(dispNames);

      /*
      [ { displayName: 'Ken' },
      { displayName: 'Rob' },
      { displayName: 'RobertGoog' },
      { displayName: 'AndersMicro' },
      { displayName: 'Ryan08' } ]
      */

      // 2nd way to get as a list of displayNames
      var dispNames2 = parsed.value.map(function(o) { return o.displayName});
      console.log(dispNames2);
      /*
      [ 'Ken', 'Rob', 'RobertGoog', 'AndersMicro', 'Ryan08' ]
      */

      // 3rd way to get as a string with displayNames separated with comma(,)
      console. log(dispNames2.join(","));
      /*
      Ken,Rob,RobertGoog,AndersMicro,Ryan08
      */


      If you want to get result as the above 3rd way shows, here is most simple way to get that without using join() method defined on array objects.



      console.log("" + dispNames2);
      // Ken,Rob,RobertGoog,AndersMicro,Ryan08






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Nov 24 '18 at 5:23


























      community wiki





      3 revs
      hygull









      • 1





        This is brilliant, thank you so much! It is exactly what I was looking to achieve. I can see the map function being very useful for me in other cases too.

        – user1780144
        Nov 27 '18 at 18:04











      • You are welcome. Thank you.

        – hygull
        Nov 27 '18 at 19:16














      • 1





        This is brilliant, thank you so much! It is exactly what I was looking to achieve. I can see the map function being very useful for me in other cases too.

        – user1780144
        Nov 27 '18 at 18:04











      • You are welcome. Thank you.

        – hygull
        Nov 27 '18 at 19:16








      1




      1





      This is brilliant, thank you so much! It is exactly what I was looking to achieve. I can see the map function being very useful for me in other cases too.

      – user1780144
      Nov 27 '18 at 18:04





      This is brilliant, thank you so much! It is exactly what I was looking to achieve. I can see the map function being very useful for me in other cases too.

      – user1780144
      Nov 27 '18 at 18:04













      You are welcome. Thank you.

      – hygull
      Nov 27 '18 at 19:16





      You are welcome. Thank you.

      – hygull
      Nov 27 '18 at 19:16













      1














      Not sure exactly what you need, but I think it will work :



      var names = parsed.value.map(function(v){ return v.displayName });


      Now names is an array containing all the displayName values.



      If you want objects with just the displayName property, then :



      var objects = parsed.value.map(function(v) { 
      return {
      displayName: v.displayName
      };
      });


      You can check MDN doc for map






      share|improve this answer






























        1














        Not sure exactly what you need, but I think it will work :



        var names = parsed.value.map(function(v){ return v.displayName });


        Now names is an array containing all the displayName values.



        If you want objects with just the displayName property, then :



        var objects = parsed.value.map(function(v) { 
        return {
        displayName: v.displayName
        };
        });


        You can check MDN doc for map






        share|improve this answer




























          1












          1








          1







          Not sure exactly what you need, but I think it will work :



          var names = parsed.value.map(function(v){ return v.displayName });


          Now names is an array containing all the displayName values.



          If you want objects with just the displayName property, then :



          var objects = parsed.value.map(function(v) { 
          return {
          displayName: v.displayName
          };
          });


          You can check MDN doc for map






          share|improve this answer















          Not sure exactly what you need, but I think it will work :



          var names = parsed.value.map(function(v){ return v.displayName });


          Now names is an array containing all the displayName values.



          If you want objects with just the displayName property, then :



          var objects = parsed.value.map(function(v) { 
          return {
          displayName: v.displayName
          };
          });


          You can check MDN doc for map







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 24 '18 at 3:42

























          answered Nov 24 '18 at 1:49









          Johnny5Johnny5

          4,10133368




          4,10133368























              0














              As Johnny5 suggests, the map function is the ideal in this case. Try this approximation where you get an array of objects like the original dataset






              const dataset = [
              {
              classification: null,
              createdDateTime: new Date('2018-03-03'),
              deletedDateTime: null,
              description: 'lorem ipsum',
              displayName: 'John Logan',
              mail: 'john.logan@domain.com',
              }, {
              classification: null,
              createdDateTime: new Date('2018-03-03'),
              deletedDateTime: null,
              description: 'lorem ipsum',
              displayName: 'Ken Master',
              mail: 'ken.master@domain.com',
              }, {
              classification: null,
              createdDateTime: new Date('2018-03-03'),
              deletedDateTime: null,
              description: 'lorem ipsum',
              displayName: 'Samus Aran',
              mail: 'samus.aran@domain.com',
              }, {
              classification: null,
              createdDateTime: new Date('2018-03-03'),
              deletedDateTime: null,
              description: 'lorem ipsum',
              displayName: 'King Dede',
              mail: 'king.dede@domain.com',
              }, {
              classification: null,
              createdDateTime: new Date('2018-03-03'),
              deletedDateTime: null,
              description: 'lorem ipsum',
              displayName: 'Monkey D Luffy',
              mail: 'luffy.monkey@domain.com',
              }
              ];

              const displayNames = dataset.map(toDisplayNameView);

              function toDisplayNameView(data) {
              return {
              displayName: data.displayName
              };
              }

              console.log(displayNames);








              share|improve this answer




























                0














                As Johnny5 suggests, the map function is the ideal in this case. Try this approximation where you get an array of objects like the original dataset






                const dataset = [
                {
                classification: null,
                createdDateTime: new Date('2018-03-03'),
                deletedDateTime: null,
                description: 'lorem ipsum',
                displayName: 'John Logan',
                mail: 'john.logan@domain.com',
                }, {
                classification: null,
                createdDateTime: new Date('2018-03-03'),
                deletedDateTime: null,
                description: 'lorem ipsum',
                displayName: 'Ken Master',
                mail: 'ken.master@domain.com',
                }, {
                classification: null,
                createdDateTime: new Date('2018-03-03'),
                deletedDateTime: null,
                description: 'lorem ipsum',
                displayName: 'Samus Aran',
                mail: 'samus.aran@domain.com',
                }, {
                classification: null,
                createdDateTime: new Date('2018-03-03'),
                deletedDateTime: null,
                description: 'lorem ipsum',
                displayName: 'King Dede',
                mail: 'king.dede@domain.com',
                }, {
                classification: null,
                createdDateTime: new Date('2018-03-03'),
                deletedDateTime: null,
                description: 'lorem ipsum',
                displayName: 'Monkey D Luffy',
                mail: 'luffy.monkey@domain.com',
                }
                ];

                const displayNames = dataset.map(toDisplayNameView);

                function toDisplayNameView(data) {
                return {
                displayName: data.displayName
                };
                }

                console.log(displayNames);








                share|improve this answer


























                  0












                  0








                  0







                  As Johnny5 suggests, the map function is the ideal in this case. Try this approximation where you get an array of objects like the original dataset






                  const dataset = [
                  {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'John Logan',
                  mail: 'john.logan@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Ken Master',
                  mail: 'ken.master@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Samus Aran',
                  mail: 'samus.aran@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'King Dede',
                  mail: 'king.dede@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Monkey D Luffy',
                  mail: 'luffy.monkey@domain.com',
                  }
                  ];

                  const displayNames = dataset.map(toDisplayNameView);

                  function toDisplayNameView(data) {
                  return {
                  displayName: data.displayName
                  };
                  }

                  console.log(displayNames);








                  share|improve this answer













                  As Johnny5 suggests, the map function is the ideal in this case. Try this approximation where you get an array of objects like the original dataset






                  const dataset = [
                  {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'John Logan',
                  mail: 'john.logan@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Ken Master',
                  mail: 'ken.master@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Samus Aran',
                  mail: 'samus.aran@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'King Dede',
                  mail: 'king.dede@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Monkey D Luffy',
                  mail: 'luffy.monkey@domain.com',
                  }
                  ];

                  const displayNames = dataset.map(toDisplayNameView);

                  function toDisplayNameView(data) {
                  return {
                  displayName: data.displayName
                  };
                  }

                  console.log(displayNames);








                  const dataset = [
                  {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'John Logan',
                  mail: 'john.logan@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Ken Master',
                  mail: 'ken.master@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Samus Aran',
                  mail: 'samus.aran@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'King Dede',
                  mail: 'king.dede@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Monkey D Luffy',
                  mail: 'luffy.monkey@domain.com',
                  }
                  ];

                  const displayNames = dataset.map(toDisplayNameView);

                  function toDisplayNameView(data) {
                  return {
                  displayName: data.displayName
                  };
                  }

                  console.log(displayNames);





                  const dataset = [
                  {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'John Logan',
                  mail: 'john.logan@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Ken Master',
                  mail: 'ken.master@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Samus Aran',
                  mail: 'samus.aran@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'King Dede',
                  mail: 'king.dede@domain.com',
                  }, {
                  classification: null,
                  createdDateTime: new Date('2018-03-03'),
                  deletedDateTime: null,
                  description: 'lorem ipsum',
                  displayName: 'Monkey D Luffy',
                  mail: 'luffy.monkey@domain.com',
                  }
                  ];

                  const displayNames = dataset.map(toDisplayNameView);

                  function toDisplayNameView(data) {
                  return {
                  displayName: data.displayName
                  };
                  }

                  console.log(displayNames);






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 24 '18 at 3:16









                  user615274user615274

                  1,4061219




                  1,4061219






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454500%2fjson-parse-to-get-objects-within-array%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Lallio

                      Futebolista

                      Jornalista