How can I iterate over a json without static main key?

I’m trying to iterate over a json object with multiple json objects inside, but the main key who allow me to access to the objects is not static , How can I iterate over those objects and at the same time to know the main key who allow me to have access to the object?

Thanks in advance

let res = {
     Zw== : { price: "500", code: "Zw==", name: "Word 2013", image: "path/d360f0.jpg", total: 1},
     aA== : { price: "300", code: "aA==", name: "Power point 2013", image: "path/80fa572.png", total: 1},
     xH== : { price: "300", code: "aA==", name: "Power point 2013", image: "path/80fa572.png", total: 1}
};

27 thoughts on “How can I iterate over a json without static main key?”

Leave a Comment