HTML
<template>
<div>
<p>Name: {myData.name}</p>
<p>Age: {myData.age}</p>
<p>Email: {myData.email}</p>
<p>Address:</p>
<ul>
<li>Street: {myData.address.street}</li>
<li>City: {myData.address.city}</li>
<li>State: {myData.address.state}</li>
<li>Zip: {myData.address.zip}</li>
</ul>
<p>Phone Numbers:</p>
<ul>
<template for:each={myData.phoneNumbers} for:item="phone">
<li key={phone.type}>{phone.type}: {phone.number}</li>
</template>
</ul>
</div>
</template>
Java Script
import { LightningElement } from 'lwc';
export default class JSONExampleSimple extends LightningElement {
myData = {
"name": "John",
"age": 30,
"email": "john@example.com",
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
},
"phoneNumbers": [
{
"type": "home",
"number": "555-555-1234"
},
{
"type": "work",
"number": "555-555-5678"
}
]
};
}
Video
Video does not exists.