Get element from json array javascriptHow do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?Can comments be used in JSON?How can I convert a string to boolean in JavaScript?What is the correct JSON content type?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?

How to align and center standalone amsmath equations?

From/by (what sounds better?)

Diode in opposite direction?

Varistor? Purpose and principle

Customize circled numbers

Is it possible to have a strip of cold climate in the middle of a planet?

A social experiment. What is the worst that can happen?

Reply ‘no position’ while the job posting is still there (‘HiWi’ position in Germany)

How should I respond when I lied about my education and the company finds out through background check?

How do I extrude a face to a single vertex

Female=gender counterpart?

THT: What is a squared annular “ring”?

Bob has never been a M before

Indicating multiple different modes of speech (fantasy language or telepathy)

How will losing mobility of one hand affect my career as a programmer?

In Star Trek IV, why did the Bounty go back to a time when whales were already rare?

Why did the EU agree to delay the Brexit deadline?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

Make "apt-get update" show the exact output as `apt update`

Did arcade monitors have same pixel aspect ratio as TV sets?

What is the smallest body in which a sling shot maneuver can be performed?

How do I repair my stair bannister?

Has Darkwing Duck ever met Scrooge McDuck?

Some numbers are more equivalent than others



Get element from json array javascript


How do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?Can comments be used in JSON?How can I convert a string to boolean in JavaScript?What is the correct JSON content type?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?













7















I have a simple Json String



[

"assetName":"LCT",
"assetValue":"",
"typeValueInput":"select",
"valueInputSelect":null,
"required":true,
"valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

]


I want get field Name in Data in ValueInput by Javascript.



Please help me!










share|improve this question



















  • 1





    You can use JSON.parse to convert json to object.

    – Eddie
    1 hour ago















7















I have a simple Json String



[

"assetName":"LCT",
"assetValue":"",
"typeValueInput":"select",
"valueInputSelect":null,
"required":true,
"valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

]


I want get field Name in Data in ValueInput by Javascript.



Please help me!










share|improve this question



















  • 1





    You can use JSON.parse to convert json to object.

    – Eddie
    1 hour ago













7












7








7








I have a simple Json String



[

"assetName":"LCT",
"assetValue":"",
"typeValueInput":"select",
"valueInputSelect":null,
"required":true,
"valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

]


I want get field Name in Data in ValueInput by Javascript.



Please help me!










share|improve this question
















I have a simple Json String



[

"assetName":"LCT",
"assetValue":"",
"typeValueInput":"select",
"valueInputSelect":null,
"required":true,
"valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

]


I want get field Name in Data in ValueInput by Javascript.



Please help me!







javascript arrays json object






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









Jack Bashford

13.1k31847




13.1k31847










asked 1 hour ago









Java Dev BeginnerJava Dev Beginner

6318




6318







  • 1





    You can use JSON.parse to convert json to object.

    – Eddie
    1 hour ago












  • 1





    You can use JSON.parse to convert json to object.

    – Eddie
    1 hour ago







1




1





You can use JSON.parse to convert json to object.

– Eddie
1 hour ago





You can use JSON.parse to convert json to object.

– Eddie
1 hour ago












8 Answers
8






active

oldest

votes


















3














You need to loop through the array and then parse the stringified JSON so that you can access the data array. Then simply loop that data array to get the value of each name property.






var arr = [
"assetName": "LCT",
"assetValue": "",
"typeValueInput": "select",
"valueInputSelect": null,
"required": true,
"valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
];

arr.forEach((arrObj) =>
var jsonData = JSON.parse(arrObj.valueInput);
jsonData.data.forEach((name) => console.log(name));
);








share|improve this answer






























    1














    You could use JSON.parse




    var jsonArray = [

    assetName: 'LCT',
    assetValue: '',
    typeValueInput: 'select',
    valueInputSelect: null,
    required: true,
    valueInput:
    '"data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]'

    ];

    let name = jsonArray[0].valueInput;
    name = JSON.parse(name);
    name.data.forEach(value =>
    console.log(value.name, value.id);
    );








    share|improve this answer






























      0














      You can use JSON.parse



      JSON.parse(o[0].valueInput).data[0].name





      var o = [

      "assetName":"LCT",
      "assetValue":"",
      "typeValueInput":"select",
      "valueInputSelect":null,
      "required":true,
      "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

      ]

      console.log(JSON.parse(o[0].valueInput).data[0].name);

      // To get all, use a loop

      var arrO = JSON.parse(o[0].valueInput).data;

      arrO.forEach((obj) => console.log(obj.name))








      share|improve this answer























      • @Deepakgupta data[0] is not a string, the array is parsed before. See the live demo before post a comment

        – R3tep
        1 hour ago











      • the input value is a string, not an object, and the string is not correctly stringified.

        – AZ_
        1 hour ago











      • @AZ_ The input value is not a string. Jack make some bad edit

        – R3tep
        1 hour ago











      • it says I have a simple Json String not sure maybe.

        – AZ_
        1 hour ago











      • @AZ_ Yes he have a json string into the key valueInput

        – R3tep
        1 hour ago


















      0














      Use JSON.parse, and use map:






      const data = [
      "assetName": "LCT",
      "assetValue": "",
      "typeValueInput": "select",
      "valueInputSelect": null,
      "required": true,
      "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
      ]
      const names = JSON.parse(data[0].valueInput).data.map(( name ) => name);
      console.log(names);








      share|improve this answer






























        0














        You can do:






        const arr = [
        "assetName": "LCT",
        "assetValue": "",
        "typeValueInput": "select",
        "valueInputSelect": null,
        "required": true,
        "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
        ];
        const namesArr = JSON.parse(arr[0].valueInput).data.map(o => o.name);

        console.log(namesArr);








        share|improve this answer






























          0














          You can use an array variable and the callback function of JSON.parse to get the name key & val






          let dt = [
          "assetName": "LCT",
          "assetValue": "",
          "typeValueInput": "select",
          "valueInputSelect": null,
          "required": true,
          "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
          ];
          let nameArray = [];

          let dlt = JSON.parse(dt[0].valueInput, function(key, val)
          if (key === 'name')
          nameArray.push(val);

          )

          console.log(nameArray)








          share|improve this answer






























            0














            Here is a way to do it.



            let originalData = [

            "assetName":"LCT",
            "assetValue":"",
            "typeValueInput":"select",
            "valueInputSelect":null,
            "required":true,
            "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

            ];

            let valueInput = JSON.parse(originalData[0].valueInput);

            let data = valueInput.data;

            console.log(data);

            for (var i = 0; i < data.length; i++)
            console.log(data[i].name);



            See jsfiddle https://jsfiddle.net/3s1na4eL/3/



            Let me know if there are any questions.






            share|improve this answer






























              0














              You can try with Array.prototype.map()




              The map() method creates a new array with the results of calling a provided function on every element in the calling array.




              JSON.parse()




              The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.




              and Array.prototype.flat()




              The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.




              like the following way:






              var data = [

              "assetName":"LCT",
              "assetValue":"",
              "typeValueInput":"select",
              "valueInputSelect":null,
              "required":true,
              "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

              ]

              var fieldNames = data.map(d => JSON.parse(d.valueInput).data.map(i => i.name)).flat(2);
              console.log(fieldNames);








              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%2f55333968%2fget-element-from-json-array-javascript%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                8 Answers
                8






                active

                oldest

                votes








                8 Answers
                8






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                3














                You need to loop through the array and then parse the stringified JSON so that you can access the data array. Then simply loop that data array to get the value of each name property.






                var arr = [
                "assetName": "LCT",
                "assetValue": "",
                "typeValueInput": "select",
                "valueInputSelect": null,
                "required": true,
                "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                ];

                arr.forEach((arrObj) =>
                var jsonData = JSON.parse(arrObj.valueInput);
                jsonData.data.forEach((name) => console.log(name));
                );








                share|improve this answer



























                  3














                  You need to loop through the array and then parse the stringified JSON so that you can access the data array. Then simply loop that data array to get the value of each name property.






                  var arr = [
                  "assetName": "LCT",
                  "assetValue": "",
                  "typeValueInput": "select",
                  "valueInputSelect": null,
                  "required": true,
                  "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                  ];

                  arr.forEach((arrObj) =>
                  var jsonData = JSON.parse(arrObj.valueInput);
                  jsonData.data.forEach((name) => console.log(name));
                  );








                  share|improve this answer

























                    3












                    3








                    3







                    You need to loop through the array and then parse the stringified JSON so that you can access the data array. Then simply loop that data array to get the value of each name property.






                    var arr = [
                    "assetName": "LCT",
                    "assetValue": "",
                    "typeValueInput": "select",
                    "valueInputSelect": null,
                    "required": true,
                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                    ];

                    arr.forEach((arrObj) =>
                    var jsonData = JSON.parse(arrObj.valueInput);
                    jsonData.data.forEach((name) => console.log(name));
                    );








                    share|improve this answer













                    You need to loop through the array and then parse the stringified JSON so that you can access the data array. Then simply loop that data array to get the value of each name property.






                    var arr = [
                    "assetName": "LCT",
                    "assetValue": "",
                    "typeValueInput": "select",
                    "valueInputSelect": null,
                    "required": true,
                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                    ];

                    arr.forEach((arrObj) =>
                    var jsonData = JSON.parse(arrObj.valueInput);
                    jsonData.data.forEach((name) => console.log(name));
                    );








                    var arr = [
                    "assetName": "LCT",
                    "assetValue": "",
                    "typeValueInput": "select",
                    "valueInputSelect": null,
                    "required": true,
                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                    ];

                    arr.forEach((arrObj) =>
                    var jsonData = JSON.parse(arrObj.valueInput);
                    jsonData.data.forEach((name) => console.log(name));
                    );





                    var arr = [
                    "assetName": "LCT",
                    "assetValue": "",
                    "typeValueInput": "select",
                    "valueInputSelect": null,
                    "required": true,
                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                    ];

                    arr.forEach((arrObj) =>
                    var jsonData = JSON.parse(arrObj.valueInput);
                    jsonData.data.forEach((name) => console.log(name));
                    );






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 1 hour ago









                    Ankit AgarwalAnkit Agarwal

                    24.3k52245




                    24.3k52245























                        1














                        You could use JSON.parse




                        var jsonArray = [

                        assetName: 'LCT',
                        assetValue: '',
                        typeValueInput: 'select',
                        valueInputSelect: null,
                        required: true,
                        valueInput:
                        '"data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]'

                        ];

                        let name = jsonArray[0].valueInput;
                        name = JSON.parse(name);
                        name.data.forEach(value =>
                        console.log(value.name, value.id);
                        );








                        share|improve this answer



























                          1














                          You could use JSON.parse




                          var jsonArray = [

                          assetName: 'LCT',
                          assetValue: '',
                          typeValueInput: 'select',
                          valueInputSelect: null,
                          required: true,
                          valueInput:
                          '"data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]'

                          ];

                          let name = jsonArray[0].valueInput;
                          name = JSON.parse(name);
                          name.data.forEach(value =>
                          console.log(value.name, value.id);
                          );








                          share|improve this answer

























                            1












                            1








                            1







                            You could use JSON.parse




                            var jsonArray = [

                            assetName: 'LCT',
                            assetValue: '',
                            typeValueInput: 'select',
                            valueInputSelect: null,
                            required: true,
                            valueInput:
                            '"data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]'

                            ];

                            let name = jsonArray[0].valueInput;
                            name = JSON.parse(name);
                            name.data.forEach(value =>
                            console.log(value.name, value.id);
                            );








                            share|improve this answer













                            You could use JSON.parse




                            var jsonArray = [

                            assetName: 'LCT',
                            assetValue: '',
                            typeValueInput: 'select',
                            valueInputSelect: null,
                            required: true,
                            valueInput:
                            '"data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]'

                            ];

                            let name = jsonArray[0].valueInput;
                            name = JSON.parse(name);
                            name.data.forEach(value =>
                            console.log(value.name, value.id);
                            );








                            var jsonArray = [

                            assetName: 'LCT',
                            assetValue: '',
                            typeValueInput: 'select',
                            valueInputSelect: null,
                            required: true,
                            valueInput:
                            '"data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]'

                            ];

                            let name = jsonArray[0].valueInput;
                            name = JSON.parse(name);
                            name.data.forEach(value =>
                            console.log(value.name, value.id);
                            );





                            var jsonArray = [

                            assetName: 'LCT',
                            assetValue: '',
                            typeValueInput: 'select',
                            valueInputSelect: null,
                            required: true,
                            valueInput:
                            '"data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]'

                            ];

                            let name = jsonArray[0].valueInput;
                            name = JSON.parse(name);
                            name.data.forEach(value =>
                            console.log(value.name, value.id);
                            );






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 1 hour ago









                            Loc MaiLoc Mai

                            4113




                            4113





















                                0














                                You can use JSON.parse



                                JSON.parse(o[0].valueInput).data[0].name





                                var o = [

                                "assetName":"LCT",
                                "assetValue":"",
                                "typeValueInput":"select",
                                "valueInputSelect":null,
                                "required":true,
                                "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                ]

                                console.log(JSON.parse(o[0].valueInput).data[0].name);

                                // To get all, use a loop

                                var arrO = JSON.parse(o[0].valueInput).data;

                                arrO.forEach((obj) => console.log(obj.name))








                                share|improve this answer























                                • @Deepakgupta data[0] is not a string, the array is parsed before. See the live demo before post a comment

                                  – R3tep
                                  1 hour ago











                                • the input value is a string, not an object, and the string is not correctly stringified.

                                  – AZ_
                                  1 hour ago











                                • @AZ_ The input value is not a string. Jack make some bad edit

                                  – R3tep
                                  1 hour ago











                                • it says I have a simple Json String not sure maybe.

                                  – AZ_
                                  1 hour ago











                                • @AZ_ Yes he have a json string into the key valueInput

                                  – R3tep
                                  1 hour ago















                                0














                                You can use JSON.parse



                                JSON.parse(o[0].valueInput).data[0].name





                                var o = [

                                "assetName":"LCT",
                                "assetValue":"",
                                "typeValueInput":"select",
                                "valueInputSelect":null,
                                "required":true,
                                "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                ]

                                console.log(JSON.parse(o[0].valueInput).data[0].name);

                                // To get all, use a loop

                                var arrO = JSON.parse(o[0].valueInput).data;

                                arrO.forEach((obj) => console.log(obj.name))








                                share|improve this answer























                                • @Deepakgupta data[0] is not a string, the array is parsed before. See the live demo before post a comment

                                  – R3tep
                                  1 hour ago











                                • the input value is a string, not an object, and the string is not correctly stringified.

                                  – AZ_
                                  1 hour ago











                                • @AZ_ The input value is not a string. Jack make some bad edit

                                  – R3tep
                                  1 hour ago











                                • it says I have a simple Json String not sure maybe.

                                  – AZ_
                                  1 hour ago











                                • @AZ_ Yes he have a json string into the key valueInput

                                  – R3tep
                                  1 hour ago













                                0












                                0








                                0







                                You can use JSON.parse



                                JSON.parse(o[0].valueInput).data[0].name





                                var o = [

                                "assetName":"LCT",
                                "assetValue":"",
                                "typeValueInput":"select",
                                "valueInputSelect":null,
                                "required":true,
                                "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                ]

                                console.log(JSON.parse(o[0].valueInput).data[0].name);

                                // To get all, use a loop

                                var arrO = JSON.parse(o[0].valueInput).data;

                                arrO.forEach((obj) => console.log(obj.name))








                                share|improve this answer













                                You can use JSON.parse



                                JSON.parse(o[0].valueInput).data[0].name





                                var o = [

                                "assetName":"LCT",
                                "assetValue":"",
                                "typeValueInput":"select",
                                "valueInputSelect":null,
                                "required":true,
                                "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                ]

                                console.log(JSON.parse(o[0].valueInput).data[0].name);

                                // To get all, use a loop

                                var arrO = JSON.parse(o[0].valueInput).data;

                                arrO.forEach((obj) => console.log(obj.name))








                                var o = [

                                "assetName":"LCT",
                                "assetValue":"",
                                "typeValueInput":"select",
                                "valueInputSelect":null,
                                "required":true,
                                "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                ]

                                console.log(JSON.parse(o[0].valueInput).data[0].name);

                                // To get all, use a loop

                                var arrO = JSON.parse(o[0].valueInput).data;

                                arrO.forEach((obj) => console.log(obj.name))





                                var o = [

                                "assetName":"LCT",
                                "assetValue":"",
                                "typeValueInput":"select",
                                "valueInputSelect":null,
                                "required":true,
                                "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                ]

                                console.log(JSON.parse(o[0].valueInput).data[0].name);

                                // To get all, use a loop

                                var arrO = JSON.parse(o[0].valueInput).data;

                                arrO.forEach((obj) => console.log(obj.name))






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered 1 hour ago









                                R3tepR3tep

                                8,00982962




                                8,00982962












                                • @Deepakgupta data[0] is not a string, the array is parsed before. See the live demo before post a comment

                                  – R3tep
                                  1 hour ago











                                • the input value is a string, not an object, and the string is not correctly stringified.

                                  – AZ_
                                  1 hour ago











                                • @AZ_ The input value is not a string. Jack make some bad edit

                                  – R3tep
                                  1 hour ago











                                • it says I have a simple Json String not sure maybe.

                                  – AZ_
                                  1 hour ago











                                • @AZ_ Yes he have a json string into the key valueInput

                                  – R3tep
                                  1 hour ago

















                                • @Deepakgupta data[0] is not a string, the array is parsed before. See the live demo before post a comment

                                  – R3tep
                                  1 hour ago











                                • the input value is a string, not an object, and the string is not correctly stringified.

                                  – AZ_
                                  1 hour ago











                                • @AZ_ The input value is not a string. Jack make some bad edit

                                  – R3tep
                                  1 hour ago











                                • it says I have a simple Json String not sure maybe.

                                  – AZ_
                                  1 hour ago











                                • @AZ_ Yes he have a json string into the key valueInput

                                  – R3tep
                                  1 hour ago
















                                @Deepakgupta data[0] is not a string, the array is parsed before. See the live demo before post a comment

                                – R3tep
                                1 hour ago





                                @Deepakgupta data[0] is not a string, the array is parsed before. See the live demo before post a comment

                                – R3tep
                                1 hour ago













                                the input value is a string, not an object, and the string is not correctly stringified.

                                – AZ_
                                1 hour ago





                                the input value is a string, not an object, and the string is not correctly stringified.

                                – AZ_
                                1 hour ago













                                @AZ_ The input value is not a string. Jack make some bad edit

                                – R3tep
                                1 hour ago





                                @AZ_ The input value is not a string. Jack make some bad edit

                                – R3tep
                                1 hour ago













                                it says I have a simple Json String not sure maybe.

                                – AZ_
                                1 hour ago





                                it says I have a simple Json String not sure maybe.

                                – AZ_
                                1 hour ago













                                @AZ_ Yes he have a json string into the key valueInput

                                – R3tep
                                1 hour ago





                                @AZ_ Yes he have a json string into the key valueInput

                                – R3tep
                                1 hour ago











                                0














                                Use JSON.parse, and use map:






                                const data = [
                                "assetName": "LCT",
                                "assetValue": "",
                                "typeValueInput": "select",
                                "valueInputSelect": null,
                                "required": true,
                                "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                ]
                                const names = JSON.parse(data[0].valueInput).data.map(( name ) => name);
                                console.log(names);








                                share|improve this answer



























                                  0














                                  Use JSON.parse, and use map:






                                  const data = [
                                  "assetName": "LCT",
                                  "assetValue": "",
                                  "typeValueInput": "select",
                                  "valueInputSelect": null,
                                  "required": true,
                                  "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                  ]
                                  const names = JSON.parse(data[0].valueInput).data.map(( name ) => name);
                                  console.log(names);








                                  share|improve this answer

























                                    0












                                    0








                                    0







                                    Use JSON.parse, and use map:






                                    const data = [
                                    "assetName": "LCT",
                                    "assetValue": "",
                                    "typeValueInput": "select",
                                    "valueInputSelect": null,
                                    "required": true,
                                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                    ]
                                    const names = JSON.parse(data[0].valueInput).data.map(( name ) => name);
                                    console.log(names);








                                    share|improve this answer













                                    Use JSON.parse, and use map:






                                    const data = [
                                    "assetName": "LCT",
                                    "assetValue": "",
                                    "typeValueInput": "select",
                                    "valueInputSelect": null,
                                    "required": true,
                                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                    ]
                                    const names = JSON.parse(data[0].valueInput).data.map(( name ) => name);
                                    console.log(names);








                                    const data = [
                                    "assetName": "LCT",
                                    "assetValue": "",
                                    "typeValueInput": "select",
                                    "valueInputSelect": null,
                                    "required": true,
                                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                    ]
                                    const names = JSON.parse(data[0].valueInput).data.map(( name ) => name);
                                    console.log(names);





                                    const data = [
                                    "assetName": "LCT",
                                    "assetValue": "",
                                    "typeValueInput": "select",
                                    "valueInputSelect": null,
                                    "required": true,
                                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                    ]
                                    const names = JSON.parse(data[0].valueInput).data.map(( name ) => name);
                                    console.log(names);






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 1 hour ago









                                    Jack BashfordJack Bashford

                                    13.1k31847




                                    13.1k31847





















                                        0














                                        You can do:






                                        const arr = [
                                        "assetName": "LCT",
                                        "assetValue": "",
                                        "typeValueInput": "select",
                                        "valueInputSelect": null,
                                        "required": true,
                                        "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                        ];
                                        const namesArr = JSON.parse(arr[0].valueInput).data.map(o => o.name);

                                        console.log(namesArr);








                                        share|improve this answer



























                                          0














                                          You can do:






                                          const arr = [
                                          "assetName": "LCT",
                                          "assetValue": "",
                                          "typeValueInput": "select",
                                          "valueInputSelect": null,
                                          "required": true,
                                          "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                          ];
                                          const namesArr = JSON.parse(arr[0].valueInput).data.map(o => o.name);

                                          console.log(namesArr);








                                          share|improve this answer

























                                            0












                                            0








                                            0







                                            You can do:






                                            const arr = [
                                            "assetName": "LCT",
                                            "assetValue": "",
                                            "typeValueInput": "select",
                                            "valueInputSelect": null,
                                            "required": true,
                                            "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                            ];
                                            const namesArr = JSON.parse(arr[0].valueInput).data.map(o => o.name);

                                            console.log(namesArr);








                                            share|improve this answer













                                            You can do:






                                            const arr = [
                                            "assetName": "LCT",
                                            "assetValue": "",
                                            "typeValueInput": "select",
                                            "valueInputSelect": null,
                                            "required": true,
                                            "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                            ];
                                            const namesArr = JSON.parse(arr[0].valueInput).data.map(o => o.name);

                                            console.log(namesArr);








                                            const arr = [
                                            "assetName": "LCT",
                                            "assetValue": "",
                                            "typeValueInput": "select",
                                            "valueInputSelect": null,
                                            "required": true,
                                            "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                            ];
                                            const namesArr = JSON.parse(arr[0].valueInput).data.map(o => o.name);

                                            console.log(namesArr);





                                            const arr = [
                                            "assetName": "LCT",
                                            "assetValue": "",
                                            "typeValueInput": "select",
                                            "valueInputSelect": null,
                                            "required": true,
                                            "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                            ];
                                            const namesArr = JSON.parse(arr[0].valueInput).data.map(o => o.name);

                                            console.log(namesArr);






                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered 1 hour ago









                                            Yosvel QuinteroYosvel Quintero

                                            11.9k42531




                                            11.9k42531





















                                                0














                                                You can use an array variable and the callback function of JSON.parse to get the name key & val






                                                let dt = [
                                                "assetName": "LCT",
                                                "assetValue": "",
                                                "typeValueInput": "select",
                                                "valueInputSelect": null,
                                                "required": true,
                                                "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                                ];
                                                let nameArray = [];

                                                let dlt = JSON.parse(dt[0].valueInput, function(key, val)
                                                if (key === 'name')
                                                nameArray.push(val);

                                                )

                                                console.log(nameArray)








                                                share|improve this answer



























                                                  0














                                                  You can use an array variable and the callback function of JSON.parse to get the name key & val






                                                  let dt = [
                                                  "assetName": "LCT",
                                                  "assetValue": "",
                                                  "typeValueInput": "select",
                                                  "valueInputSelect": null,
                                                  "required": true,
                                                  "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                                  ];
                                                  let nameArray = [];

                                                  let dlt = JSON.parse(dt[0].valueInput, function(key, val)
                                                  if (key === 'name')
                                                  nameArray.push(val);

                                                  )

                                                  console.log(nameArray)








                                                  share|improve this answer

























                                                    0












                                                    0








                                                    0







                                                    You can use an array variable and the callback function of JSON.parse to get the name key & val






                                                    let dt = [
                                                    "assetName": "LCT",
                                                    "assetValue": "",
                                                    "typeValueInput": "select",
                                                    "valueInputSelect": null,
                                                    "required": true,
                                                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                                    ];
                                                    let nameArray = [];

                                                    let dlt = JSON.parse(dt[0].valueInput, function(key, val)
                                                    if (key === 'name')
                                                    nameArray.push(val);

                                                    )

                                                    console.log(nameArray)








                                                    share|improve this answer













                                                    You can use an array variable and the callback function of JSON.parse to get the name key & val






                                                    let dt = [
                                                    "assetName": "LCT",
                                                    "assetValue": "",
                                                    "typeValueInput": "select",
                                                    "valueInputSelect": null,
                                                    "required": true,
                                                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                                    ];
                                                    let nameArray = [];

                                                    let dlt = JSON.parse(dt[0].valueInput, function(key, val)
                                                    if (key === 'name')
                                                    nameArray.push(val);

                                                    )

                                                    console.log(nameArray)








                                                    let dt = [
                                                    "assetName": "LCT",
                                                    "assetValue": "",
                                                    "typeValueInput": "select",
                                                    "valueInputSelect": null,
                                                    "required": true,
                                                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                                    ];
                                                    let nameArray = [];

                                                    let dlt = JSON.parse(dt[0].valueInput, function(key, val)
                                                    if (key === 'name')
                                                    nameArray.push(val);

                                                    )

                                                    console.log(nameArray)





                                                    let dt = [
                                                    "assetName": "LCT",
                                                    "assetValue": "",
                                                    "typeValueInput": "select",
                                                    "valueInputSelect": null,
                                                    "required": true,
                                                    "valueInput": ""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"
                                                    ];
                                                    let nameArray = [];

                                                    let dlt = JSON.parse(dt[0].valueInput, function(key, val)
                                                    if (key === 'name')
                                                    nameArray.push(val);

                                                    )

                                                    console.log(nameArray)






                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered 1 hour ago









                                                    brkbrk

                                                    29.1k32243




                                                    29.1k32243





















                                                        0














                                                        Here is a way to do it.



                                                        let originalData = [

                                                        "assetName":"LCT",
                                                        "assetValue":"",
                                                        "typeValueInput":"select",
                                                        "valueInputSelect":null,
                                                        "required":true,
                                                        "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                        ];

                                                        let valueInput = JSON.parse(originalData[0].valueInput);

                                                        let data = valueInput.data;

                                                        console.log(data);

                                                        for (var i = 0; i < data.length; i++)
                                                        console.log(data[i].name);



                                                        See jsfiddle https://jsfiddle.net/3s1na4eL/3/



                                                        Let me know if there are any questions.






                                                        share|improve this answer



























                                                          0














                                                          Here is a way to do it.



                                                          let originalData = [

                                                          "assetName":"LCT",
                                                          "assetValue":"",
                                                          "typeValueInput":"select",
                                                          "valueInputSelect":null,
                                                          "required":true,
                                                          "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                          ];

                                                          let valueInput = JSON.parse(originalData[0].valueInput);

                                                          let data = valueInput.data;

                                                          console.log(data);

                                                          for (var i = 0; i < data.length; i++)
                                                          console.log(data[i].name);



                                                          See jsfiddle https://jsfiddle.net/3s1na4eL/3/



                                                          Let me know if there are any questions.






                                                          share|improve this answer

























                                                            0












                                                            0








                                                            0







                                                            Here is a way to do it.



                                                            let originalData = [

                                                            "assetName":"LCT",
                                                            "assetValue":"",
                                                            "typeValueInput":"select",
                                                            "valueInputSelect":null,
                                                            "required":true,
                                                            "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                            ];

                                                            let valueInput = JSON.parse(originalData[0].valueInput);

                                                            let data = valueInput.data;

                                                            console.log(data);

                                                            for (var i = 0; i < data.length; i++)
                                                            console.log(data[i].name);



                                                            See jsfiddle https://jsfiddle.net/3s1na4eL/3/



                                                            Let me know if there are any questions.






                                                            share|improve this answer













                                                            Here is a way to do it.



                                                            let originalData = [

                                                            "assetName":"LCT",
                                                            "assetValue":"",
                                                            "typeValueInput":"select",
                                                            "valueInputSelect":null,
                                                            "required":true,
                                                            "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                            ];

                                                            let valueInput = JSON.parse(originalData[0].valueInput);

                                                            let data = valueInput.data;

                                                            console.log(data);

                                                            for (var i = 0; i < data.length; i++)
                                                            console.log(data[i].name);



                                                            See jsfiddle https://jsfiddle.net/3s1na4eL/3/



                                                            Let me know if there are any questions.







                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered 1 hour ago









                                                            Kabelo TookaKabelo Tooka

                                                            186110




                                                            186110





















                                                                0














                                                                You can try with Array.prototype.map()




                                                                The map() method creates a new array with the results of calling a provided function on every element in the calling array.




                                                                JSON.parse()




                                                                The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.




                                                                and Array.prototype.flat()




                                                                The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.




                                                                like the following way:






                                                                var data = [

                                                                "assetName":"LCT",
                                                                "assetValue":"",
                                                                "typeValueInput":"select",
                                                                "valueInputSelect":null,
                                                                "required":true,
                                                                "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                                ]

                                                                var fieldNames = data.map(d => JSON.parse(d.valueInput).data.map(i => i.name)).flat(2);
                                                                console.log(fieldNames);








                                                                share|improve this answer





























                                                                  0














                                                                  You can try with Array.prototype.map()




                                                                  The map() method creates a new array with the results of calling a provided function on every element in the calling array.




                                                                  JSON.parse()




                                                                  The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.




                                                                  and Array.prototype.flat()




                                                                  The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.




                                                                  like the following way:






                                                                  var data = [

                                                                  "assetName":"LCT",
                                                                  "assetValue":"",
                                                                  "typeValueInput":"select",
                                                                  "valueInputSelect":null,
                                                                  "required":true,
                                                                  "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                                  ]

                                                                  var fieldNames = data.map(d => JSON.parse(d.valueInput).data.map(i => i.name)).flat(2);
                                                                  console.log(fieldNames);








                                                                  share|improve this answer



























                                                                    0












                                                                    0








                                                                    0







                                                                    You can try with Array.prototype.map()




                                                                    The map() method creates a new array with the results of calling a provided function on every element in the calling array.




                                                                    JSON.parse()




                                                                    The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.




                                                                    and Array.prototype.flat()




                                                                    The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.




                                                                    like the following way:






                                                                    var data = [

                                                                    "assetName":"LCT",
                                                                    "assetValue":"",
                                                                    "typeValueInput":"select",
                                                                    "valueInputSelect":null,
                                                                    "required":true,
                                                                    "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                                    ]

                                                                    var fieldNames = data.map(d => JSON.parse(d.valueInput).data.map(i => i.name)).flat(2);
                                                                    console.log(fieldNames);








                                                                    share|improve this answer















                                                                    You can try with Array.prototype.map()




                                                                    The map() method creates a new array with the results of calling a provided function on every element in the calling array.




                                                                    JSON.parse()




                                                                    The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.




                                                                    and Array.prototype.flat()




                                                                    The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.




                                                                    like the following way:






                                                                    var data = [

                                                                    "assetName":"LCT",
                                                                    "assetValue":"",
                                                                    "typeValueInput":"select",
                                                                    "valueInputSelect":null,
                                                                    "required":true,
                                                                    "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                                    ]

                                                                    var fieldNames = data.map(d => JSON.parse(d.valueInput).data.map(i => i.name)).flat(2);
                                                                    console.log(fieldNames);








                                                                    var data = [

                                                                    "assetName":"LCT",
                                                                    "assetValue":"",
                                                                    "typeValueInput":"select",
                                                                    "valueInputSelect":null,
                                                                    "required":true,
                                                                    "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                                    ]

                                                                    var fieldNames = data.map(d => JSON.parse(d.valueInput).data.map(i => i.name)).flat(2);
                                                                    console.log(fieldNames);





                                                                    var data = [

                                                                    "assetName":"LCT",
                                                                    "assetValue":"",
                                                                    "typeValueInput":"select",
                                                                    "valueInputSelect":null,
                                                                    "required":true,
                                                                    "valueInput":""data":["name":"name1","id":"12","name":"name2","id":"13","name":"name3","id":"14"]"

                                                                    ]

                                                                    var fieldNames = data.map(d => JSON.parse(d.valueInput).data.map(i => i.name)).flat(2);
                                                                    console.log(fieldNames);






                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited 1 hour ago

























                                                                    answered 1 hour ago









                                                                    MamunMamun

                                                                    29.8k71931




                                                                    29.8k71931



























                                                                        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%2f55333968%2fget-element-from-json-array-javascript%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

                                                                        Saint-André (Pyrenaeus Orientalis) Nexus interni Nexus externi | Tabula navigationisOpenStreetMapGeoNames66168De hoc commune apud cassini.ehess.frHuius communis pagina interretialisAmplifica

                                                                        Was Objective-C really a hindrance to Apple software development? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Was there any commercially available graphical interfaces before the apple Lisa?What was the first language with regexes?Unknown Apple to VGA adapterWhat was this Apple external CRT monitor that looked like an iMac G3?A good method for formatting a modern device in HFS (Not HFS+)What Apple computers are shown in this MacBook Pro Reveal video?Help identify old Apple game from 80s (Apple II, Apple IIGS)First language designed to be embedded?What exactly did Sony contribute to the original Apple PowerBook?How was it back then in 1984, when the Apple II had color, and the new Macintosh didn't?