===========================GET FIRST NAME form JSON
const person = {
firstName: 'John',
lastName: 'Doe',
age: 25
};
for (const key in data) {
console.log('...MMMM....' + data.firstName);
}
===OUTPUT==========================================
John
+++++++++++++++++++++++++++++++++++++++++++++++++++
calculate total from multijson file
const services = [
{service: "POTATO", price: 200},
{service: "GAS", price: 100},
{service: "Freez", price: 350},
{service: "Has", price: 50}
]
let total = 0;
services.forEach(item => {
total = total + item.price
})
console.log(' Total -----:' + total);
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
===========================GET FIRST NAME form JSON
const person = {
firstName: 'John',
lastName: 'Doe',
age: 25
};
for (const key in data) {
console.log('...MMMM....' + data.firstName);
}
===OUTPUT==========================================
John
====React GET Local Storage JSON data====================================================
{
"message": "success",
"messagedata": [
{
"ID": 132,
"FullName": "Hasan Mia",
"Email": "ma100@gmail.com",
"MobNo": "22222222222",
"UserName": "ma100",
"userpassword": "12345678",
"c_userpassword": "12345678",
"User_Id": "1c5c8953-cdfe-4b4d-b93b-711030047b63",
"CreatedDt": "2024-03-02T09:51:47.463Z",
"IsVerify": null,
"IsActive": null,
"LicenceDays": null,
"JwtToken_Issue": null,
"JwtToken_Expiry": null,
"JwtUUID": null,
"JwtToken": null,
"Role_Id": 0
}
]
}
localStorage.setItem("userinfo", JSON.stringify(response.messagedata));
//get JSON data from localstorage
const data = localStorage.getItem("userinfo");
// let userinfomation = JSON.stringify(data);
let item = JSON.parse(data, null, -1);
console.log("ddddd...." + item[0]["User_Id"]);
====OUTPUT================================================================================
UserName: "1c5c8953-cdfe-4b4d-b93b-711030047b63"