0

I have a JSON file that has several main keys, and I do not know how to loop through them. I have this:

function JsonDataDisplay(){
const DisplayData=JsonData.first_object.map(
    (info)=>{
        return(
            <tr>
                <td>{info.name}</td>
                <td>{info.lastModified}</td>
                <td>{info.etag}</td>
            </tr>
        )
    }
)

The problem with the code above is that I have to type one of the main values manually, such as "first_object". How can I avoid that and loop through all of them instead?

SHC MostWanted
  • 101
  • 1
  • 7
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values – Roberto Zvjerković Feb 21 '23 at 11:33
  • JSON is a *textual notation* for data exchange. [(More here.)](http://stackoverflow.com/a/2904181/157247) If you're dealing with JavaScript source code, and not dealing with a *string*, you're not dealing with JSON. It sounds like you're just trying to loop through an object. See the linked question's answers. (If you **do** have a string, parse it [`JSON.parse`] and then loop the result.) – T.J. Crowder Feb 21 '23 at 11:35

0 Answers0