[
{
"general": [
{
"firstName": "Liana",
"lastName": "Crooks",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/kevinoh/128.jpg"
}
],
"job": [
{
"company": "Ledner, Johnson and Predovic",
"title": "Investor Functionality Coordinator"
}
],
"contact": [
{
"email": "Gerry_Hackett77@gmail.com",
"phone": "(895) 984-0132"
}
],
"address": [
{
"street": "1520 Zemlak Cove",
"city": "New Devon",
"zipCode": "42586-7898",
"country": "Guinea-Bissau"
}
]
},
{
"general": [
{
"firstName": "Deontae",
"lastName": "Dare",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/andysolomon/128.jpg"
}
],
"job": [
{
"company": "D'Amore, Dicki and Borer",
"title": "International Applications Consultant"
}
],
"contact": [
{
"email": "Kellie.Marvin38@yahoo.com",
"phone": "1-615-843-3426 x600"
}
],
"address": [
{
"street": "65901 Glover Terrace",
"city": "Alden ton",
"zipCode": "57744-4248",
"country": "Kenya"
}
]
}
]
{
"a": {
"general": [
{
"firstName": "Liana",
"lastName": "Crooks",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/kevinoh/128.jpg"
}
],
"job": [
{
"company": "Ledner, Johnson and Predovic",
"title": "Investor Functionality Coordinator"
}
],
"contact": [
{
"email": "Gerry_Hackett77@gmail.com",
"phone": "(895) 984-0132"
}
],
"address": [
{
"street": "1520 Zemlak Cove",
"city": "New Devon",
"zipCode": "42586-7898",
"country": "Guinea-Bissau"
}
]
},
"b": {
"general": [
{
"firstName": "Deontae",
"lastName": "Dare",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/andysolomon/128.jpg"
}
],
"job": [
{
"company": "D'Amore, Dicki and Borer",
"title": "International Applications Consultant"
}
],
"contact": [
{
"email": "Kellie.Marvin38@yahoo.com",
"phone": "1-615-843-3426 x600"
}
],
"address": [
{
"street": "65901 Glover Terrace",
"city": "Alden ton",
"zipCode": "57744-4248",
"country": "Kenya"
}
]
}
}
{
"data": [
{
"general": {
"firstName": "Liana",
"lastName": "Crooks",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/kevinoh/128.jpg"
},
"job": {
"company": "Ledner, Johnson and Predovic",
"title": "Investor Functionality Coordinator"
},
"contact": {
"email": "Gerry_Hackett77@gmail.com",
"phone": "(895) 984-0132"
},
"address": {
"street": "1520 Zemlak Cove",
"city": "New Devon",
"zipCode": "42586-7898",
"country": "Guinea-Bissau"
}
},
{
"general": {
"firstName": "Deontae",
"lastName": "Dare",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/andysolomon/128.jpg"
},
"job": {
"company": "D'Amore, Dicki and Borer",
"title": "International Applications Consultant"
},
"contact": {
"email": "Kellie.Marvin38@yahoo.com",
"phone": "1-615-843-3426 x600"
},
"address": {
"street": "65901 Glover Terrace",
"city": "Alden ton",
"zipCode": "57744-4248",
"country": "Kenya"
}
}
]
}
Comment
- судя по имени и по коду, он должен рендерить один комментарий, а у вас массив. Наверное, тут нужен ещё один компонент - список комментариев.const Comment = ({ general, job, address }) => (
<li>
<div>first name: {general.firstName}</div>
<div>last name: {general.lastName}</div>
<div>company: {job.company}</div>
<div>address: {address.country}, {address.city}, {address.street}</div>
</li>
);
const CommentList = ({ comments }) => (
<ul>
{comments.map(n => <Comment {...n} />)}
</ul>
);
ReactDOM.render(
<CommentList comments={comments} />,
document.getElementById('root')
);
Unexpected token g in JSON at position 4
const json = JSON.stringify([
{
general: { /* ... */ },
/* ... */
},
/* ... */
]);
const comments = JSON.parse(json);