Hello,
There is data as below.
data = [{ 'a' : '1', 'b' : '2' , 'c' : '3' } , { 'd' : '4', 'e' : '5', 'f' : '6' }, { 'g' : '7', 'h' : '8', 'i' : '9' }]
This
'a' : '1', 'b' : '2' , 'c' : '3'
'd' : '4', 'e' : '5', 'f' : '6'
'g' : '7', 'h' : '8', 'i' : '9'
Is there a way to print it out in javascript like this?
javascript list
var data = [
{ { 'a' : '1', 'b' : '2' , 'c' : '3' },
{ { 'd' : '4', 'e' : '5', 'f' : '6' },
{ { 'g' : '7', 'h' : '8', 'i' : '9' }
];
// The data is an array of objects (corresponding to the dict of the Python) (corresponding to the list of Pythons).
// So if you go around the data...
data.forEach((obj) => {
// ...You can do something with each object (corresponding to Python's dict).
// Convert this to a JSON string and then...
let str = JSON.stringify(obj);
// Let's subtract the first "{" and the last "}" and print it out.
console.log(str.substring(1, str.length - 1));
});
© 2024 OneMinuteCode. All rights reserved.