How to create csv/excel file from response data reactjs - javascript

I have response data like below:
{
"Aerospace": [
{
"id": 62,
"branch": "Aerospace",
"classification": "Einstufungen 2",
"theme": "Produktentwicklung",
"branch_id": 1,
"classification_id": 1,
"projectno": "510",
"project_id": 52,
"theme_id": 6,
"projectname": "test 22",
"comment": "",
"customername": "test 12",
"lead1id": 14,
"lead1name": "DateTest",
"lead1percent": "1000000000.0",
"lead2id": 11,
"lead2name": "logintest",
"lead2percent": "2000000000.0",
"lead3id": 16,
"lead3name": "jomo",
"lead3percent": "3000000000.0",
"leadplan_probability": "100.0",
"leadplan_plan2": "200.0",
"leadplan_plan3": "300.0",
"leadplan_addcosts": "500.0",
"leadplan_fee": "400.0",
"lead_plans": [
{
"id": 15,
"lead_id": 62,
"addcosts": "500.0",
"fee": "400.0",
"plan2": "200.0",
"plan3": "300.0",
"probability": "100.0",
"year": 2020
},
{
"id": 18,
"lead_id": 62,
"addcosts": "600.0",
"fee": "500.0",
"plan2": "200.0",
"plan3": "400.0",
"probability": "100.0",
"year": 2020
},
{
"id": 19,
"lead_id": 62,
"addcosts": "500.0",
"fee": "400.0",
"plan2": "200.0",
"plan3": "300.0",
"probability": "100.0",
"year": 2020
}
],
"offers": [
{
"id": 53,
"lead_id": 62,
"addcosts": "400.0",
"addcostsinfo": "test5",
"days": null,
"decision": "test6",
"decisiondate": "2020-05-29",
"fee": "200.0",
"mail": "test",
"offerdate": "2020-05-22",
"paper": "test"
}
]
},
{
"leadplan_plan2": 200,
"leadplan_plan3": 300,
"leadplan_addcosts": 500,
"leadplan_fee": 400
}
],
"Electrical": [
{
"id": 65,
"branch": "Electrical",
"classification": "Einstufungen 2",
"theme": "Sales",
"branch_id": 2,
"classification_id": 1,
"projectno": "12345",
"project_id": 53,
"theme_id": 5,
"projectname": "project12345",
"comment": "test",
"customername": "test123",
"lead1id": 1,
"lead1name": "alpha1",
"lead1percent": "100.0",
"lead2id": 53,
"lead2name": "newuser",
"lead2percent": "200.0",
"lead3id": 51,
"lead3name": "testisbah",
"lead3percent": "300.0",
"leadplan_probability": "1000.0",
"leadplan_plan2": "200.0",
"leadplan_plan3": "300.0",
"leadplan_addcosts": "500.0",
"leadplan_fee": "4000.0",
"lead_plans": [
{
"id": 16,
"lead_id": 65,
"addcosts": "500.0",
"fee": "4000.0",
"plan2": "200.0",
"plan3": "300.0",
"probability": "1000.0",
"year": 2020
},
{
"id": 22,
"lead_id": 65,
"addcosts": "800.0",
"fee": "700.0",
"plan2": "500.0",
"plan3": "600.0",
"probability": "400.0",
"year": 2023
}
],
"offers": [
{
"id": 52,
"lead_id": 65,
"addcosts": "400.0",
"addcostsinfo": "4",
"days": null,
"decision": "4",
"decisiondate": "2020-05-20",
"fee": "400.0",
"mail": "4",
"offerdate": "2020-05-20",
"paper": "4"
},
{
"id": 55,
"lead_id": 65,
"addcosts": "0.0",
"addcostsinfo": "",
"days": null,
"decision": "",
"decisiondate": "2020-05-13",
"fee": "0.0",
"mail": "",
"offerdate": "2020-05-14",
"paper": ""
},
{
"id": 57,
"lead_id": 65,
"addcosts": "0.0",
"addcostsinfo": "",
"days": null,
"decision": "",
"decisiondate": "2020-05-31",
"fee": "0.0",
"mail": "",
"offerdate": "2020-05-09",
"paper": ""
},
{
"id": 56,
"lead_id": 65,
"addcosts": "0.0",
"addcostsinfo": "",
"days": null,
"decision": "",
"decisiondate": "2020-05-30",
"fee": "100.0",
"mail": "",
"offerdate": "2020-05-14",
"paper": ""
},
{
"id": 58,
"lead_id": 65,
"addcosts": "0.0",
"addcostsinfo": "",
"days": null,
"decision": "",
"decisiondate": "2020-05-06",
"fee": "0.0",
"mail": "",
"offerdate": "2020-05-14",
"paper": ""
}
]
},
{
"leadplan_plan2": 200,
"leadplan_plan3": 300,
"leadplan_addcosts": 500,
"leadplan_fee": 4000
}
]
}
And I would like to create an excel or CSV file from it but problem is that my data loads first and excel utility gives error related to null empty.
Is there any reasonable excel npm package from which I can export my data to csv/excel using button click in ReactJs?
If I would be able to export my complete table, that would be good.
The result excel view would be like:

Related

Filtered JSON arrays to push into one array?

I want to filter cars in one array. So in html code, there are a lot of checkboxes. If I check the gasoline checkbox, then in the filtered array should be only the cars with gasoline, when I check the doors4 checkbox, in the filtered array should be the gasoline cars with 4 doors. etc. So how can I resolve this?
Between I try to make the same as this one here: https://www.kia.com/de/modelle/entdecken-sie-die-kia-modelle/ - when you click on the big black button, then there will be a filter.
I know how to filter it by Key-value, but that's it, I don't know what should be the next step.
let engineDiesel = cars.filter(model => model.engine === 'diesel');
let engineGasoline = cars.filter(model => model.engine === 'gasoline');
{
"models": [
{
"name": "Kia Picanto",
"category": "kompakt",
"image": "picanto.png",
"price": 10750,
"monthlyPrice": 122,
"engine": "gasoline",
"doors": 4,
"seats": 4,
"drive": "2wd",
"transmission": "manual",
"efficiency": "c"
},
{
"name": "Kia Rio",
"category": "kompakt",
"image": "rio.png",
"price": 14590,
"monthlyPrice": 147,
"engine": "hybrid",
"doors": 5,
"seats": 5,
"drive": "4wd",
"transmission": "automatic",
"efficiency": "a"
},
{
"name": "Kia Stonic",
"category": "suv",
"image": "stonic.png",
"price": 16650,
"monthlyPrice": 177,
"engine": "diesel",
"doors": 5,
"seats": 4,
"drive": "2wd",
"transmission": "automatic",
"efficiency": "d"
},
{
"name": "Kia e-Soul",
"category": "limusine",
"image": "e-Soul",
"price": 37590,
"monthlyPrice": 291,
"engine": "electro",
"doors": 4,
"seats": 4,
"drive": "4wd",
"transmission": "manual",
"efficiency": "a"
},
{
"name": "Kia Ceed",
"category": "gt",
"image": "ceed.png",
"price": 16990,
"monthlyPrice": 127,
"engine": "gasoline",
"doors": 5,
"seats": 5,
"drive": "2wd",
"transmission": "manual",
"efficiency": "a"
}
]
}
Use Array.prototype.every on an object with the conditions you want
const data = {
"models": [{
"name": "Kia Picanto",
"category": "kompakt",
"image": "picanto.png",
"price": 10750,
"monthlyPrice": 122,
"engine": "gasoline",
"doors": 4,
"seats": 4,
"drive": "2wd",
"transmission": "manual",
"efficiency": "c"
},
{
"name": "Kia Rio",
"category": "kompakt",
"image": "rio.png",
"price": 14590,
"monthlyPrice": 147,
"engine": "hybrid",
"doors": 5,
"seats": 5,
"drive": "4wd",
"transmission": "automatic",
"efficiency": "a"
},
{
"name": "Kia Stonic",
"category": "suv",
"image": "stonic.png",
"price": 16650,
"monthlyPrice": 177,
"engine": "diesel",
"doors": 5,
"seats": 4,
"drive": "2wd",
"transmission": "automatic",
"efficiency": "d"
},
{
"name": "Kia e-Soul",
"category": "limusine",
"image": "e-Soul",
"price": 37590,
"monthlyPrice": 291,
"engine": "electro",
"doors": 4,
"seats": 4,
"drive": "4wd",
"transmission": "manual",
"efficiency": "a"
},
{
"name": "Kia Ceed",
"category": "gt",
"image": "ceed.png",
"price": 16990,
"monthlyPrice": 127,
"engine": "gasoline",
"doors": 5,
"seats": 5,
"drive": "2wd",
"transmission": "manual",
"efficiency": "a"
}
]
}
const query = {
engine: x => x === "gasoline" || x === "diesel",
doors: 4,
price: x => x > 1000
}
const result = data.models.filter(car => Object.entries(query).every(([key, value]) =>
(typeof value === "function") ? value(car[key]) : (car[key] === value)
))
console.log(result)
A filter returns an array, so you can always just chain filters if that works best for your solution.
const cars = {
"models": [
{
"name": "Kia Picanto",
"category": "kompakt",
"image": "picanto.png",
"price": 10750,
"monthlyPrice": 122,
"engine": "gasoline",
"doors": 4,
"seats": 4,
"drive": "2wd",
"transmission": "manual",
"efficiency": "c"
},
{
"name": "Kia Rio",
"category": "kompakt",
"image": "rio.png",
"price": 14590,
"monthlyPrice": 147,
"engine": "hybrid",
"doors": 5,
"seats": 5,
"drive": "4wd",
"transmission": "automatic",
"efficiency": "a"
},
{
"name": "Kia Stonic",
"category": "suv",
"image": "stonic.png",
"price": 16650,
"monthlyPrice": 177,
"engine": "diesel",
"doors": 5,
"seats": 4,
"drive": "2wd",
"transmission": "automatic",
"efficiency": "d"
},
{
"name": "Kia e-Soul",
"category": "limusine",
"image": "e-Soul",
"price": 37590,
"monthlyPrice": 291,
"engine": "electro",
"doors": 4,
"seats": 4,
"drive": "4wd",
"transmission": "manual",
"efficiency": "a"
},
{
"name": "Kia Ceed",
"category": "gt",
"image": "ceed.png",
"price": 16990,
"monthlyPrice": 127,
"engine": "gasoline",
"doors": 5,
"seats": 5,
"drive": "2wd",
"transmission": "manual",
"efficiency": "a"
}
]
}
let engineGasolineWithFourDoors = cars.models
.filter(model => model.engine === 'gasoline')
.filter(model => model.doors === 4)
console.log(engineGasolineWithFourDoors);

How do I use Object.entries(...).forEach.every?

I'm filtering a list using a const queryModifier = {price: "lessThan", weight: "greaterThan"}
const queryKeys = keys: {
price: '1000',
weight: '1000'
}
const list = [
{
"clientOrderNumber": "N / A",
"companyName": "Test Company",
"createdAt": "2019-11-05 10:48:18",
"createdBy": "test#test.com",
"deliveryDate": "2019-11-08 10:46:37",
"driver": "",
"dropOff": "Kögel Trailer GmbH & Co. KG, Am Kögel-Werk, Burtenbach, Germany",
"height": 0,
"isPreparingTrailer": false,
"isSmsSent": false,
"isTrailerReady": false,
"key": "7e249529-d089-47bb-b0ad-470f850dd8cf",
"notes": "",
"orderId": "",
"pickUp": "Altenberge, Germany",
"price": 500,
"quantity": 1,
"trailer": "einzeln",
"vehicle": "Sattel",
"vehicleClass": "engl. Anschlüsse",
"vehicleId": "505123",
"vehicleReadyDate": "2019-11-05 10:47:57",
"weight": 0
},
{
"additionalPrices": 0,
"clientOrderNumber": "N / A",
"companyName": "Test Company",
"createdAt": "2019-10-14 16:32:12",
"createdBy": "test#test.com",
"deliveryDate": "2019-10-19 16:26:35",
"driver": "",
"dropOff": "Marville-Moutiers-Brûlé, France",
"height": 600,
"isPreparingTrailer": false,
"isSmsSent": false,
"isTrailerReady": false,
"key": "9b7f57fd-f95e-4038-b120-a0301fdf3f31",
"notes": "",
"orderId": "",
"pickUp": "Altenberge, Germany",
"price": 0,
"quantity": 1,
"trailer": "2er Pack",
"vehicle": "Anhänger",
"vehicleClass": "50",
"vehicleId": "123",
"vehicleReadyDate": "2019-10-16 16:31:26",
"weight": 12000
},
{
"clientOrderNumber": "N / A",
"companyName": "Test Company",
"createdAt": "2019-10-14 16:25:54",
"createdBy": "test#test.com",
"deliveryDate": "2019-10-19 16:24:13",
"driver": "",
"dropOff": "Vendenheim, France",
"height": 0,
"isPreparingTrailer": false,
"isSmsSent": false,
"isTrailerReady": false,
"key": "7e4f233f-695b-40eb-a0ca-fd78f3fa43cd",
"notes": "",
"orderId": "",
"pickUp": "Altenberge, Germany",
"price": 793,
"quantity": 1,
"trailer": "einzeln",
"vehicle": "Sattel",
"vehicleClass": "Standard",
"vehicleId": "3340731",
"vehicleReadyDate": "2019-10-15 16:24:58",
"weight": 0
},
{
"clientOrderNumber": "N / A",
"companyName": "Test Company",
"createdAt": "2019-09-26 18:32:18",
"createdBy": "test#test.com",
"deliveryDate": "2019-09-20 18:31:45",
"driver": "Michal Kucharski",
"dropOff": "Logroño, Spain",
"height": 0,
"isPreparingTrailer": false,
"isSmsSent": false,
"isTrailerReady": false,
"key": "388113f5-3927-4fe3-80d5-f2fcf1c7cedd",
"notes": "",
"orderId": "",
"pickUp": "16671 Butano Place, Fontana, CA, USA",
"price": 0,
"quantity": 1,
"trailer": "2er Pack",
"vehicle": "Sattel",
"vehicleClass": "Standard",
"vehicleId": "efgefg",
"vehicleReadyDate": "2019-09-27 18:32:08",
"weight": 0
},
{
"additionalPrices": 0,
"clientOrderNumber": "N / A",
"companyName": "Test Company",
"createdAt": "2019-09-06 22:57:55",
"createdBy": "test#test.com",
"deliveryDate": "2019-09-07 22:57:03",
"driver": "Eugeniusz Galinski",
"dropOff": "12345 Lamplight Village Avenue, Austin, TX, USA",
"height": 32,
"isPreparingTrailer": false,
"isSmsSent": false,
"isTrailerReady": false,
"key": "ac3cf14e-b43b-45e4-9168-ad4997b6415d",
"notes": "Nzube I am adding notes here",
"pickUp": "16671 Butano Place, Fontana, CA, USA",
"price": 100,
"quantity": 3,
"trailer": "einzeln",
"vehicle": "Sattel",
"vehicleClass": "Mega",
"vehicleId": "123",
"vehicleReadyDate": "2019-09-26 22:57:36",
"weight": 12
},
{
"additionalPrices": 0,
"clientOrderNumber": "N / A",
"companyName": "Test Company",
"createdAt": "2019-09-06 22:46:25",
"createdBy": "test#test.com",
"deliveryDate": "2019-09-06 22:45:45",
"driver": "Michal Kucharski",
"dropOff": "QEW, Niagara Falls, ON, Canada",
"height": 67,
"isPreparingTrailer": false,
"isSmsSent": false,
"isTrailerReady": false,
"key": "d0ec3b82-2279-4d11-8e35-a9307713ae5a",
"notes": "This is coming along",
"pickUp": "Avenida Callao 1234, Buenos Aires, Argentina",
"price": 100,
"quantity": 1,
"trailer": "2er Pack",
"vehicle": "Sattel",
"vehicleClass": "Mega",
"vehicleId": "123",
"vehicleReadyDate": "2019-09-25 22:45:57",
"weight": 12
},
{
"additionalPrices": 0,
"clientOrderNumber": "N / A",
"companyName": "Test Company",
"createdAt": "2019-09-04 18:06:18",
"createdBy": "test#test.com",
"deliveryDate": "2019-09-05 18:05:51",
"driver": "Chibuzo ilogu",
"dropOff": "Asda Park Royal Superstore, Western Road, London, UK",
"height": 453,
"isPreparingTrailer": true,
"isSmsSent": true,
"isTrailerReady": true,
"key": "96ee9410-4d70-4bbc-8016-5d7c9e5ecec1",
"notes": "ewriupoi ",
"pickUp": "Avenida Juan Bautista Alberdi 1233, Buenos Aires, Argentina",
"price": 234,
"quantity": 1,
"trailer": "3er Pack",
"vehicle": "Anhänger",
"vehicleClass": "50",
"vehicleId": "543",
"vehicleReadyDate": "2019-09-21 18:06:03",
"weight": 453
},
{
"additionalPrices": 0,
"companyName": "Test Company",
"completeDate": "2019-09-04 18:02:27",
"createdAt": "2019-09-04 18:01:30",
"createdBy": "test#test.com",
"deliveryDate": "2019-09-04 18:01:09",
"driver": "Chibuzo ilogu",
"dropOff": "La Cabaña 123, Las Condes, Chile",
"height": 123,
"isPreparingTrailer": false,
"isSmsSent": true,
"isTrailerReady": true,
"key": "bcd50f43-0644-49a7-8bdc-009a4572341b",
"notes": "qewqe",
"pickUp": "La Cabaña 123, Las Condes, Chile",
"price": 123,
"trailer": "einzeln",
"vehicle": "Sattel",
"vehicleClass": "Standard",
"vehicleId": "123",
"vehicleReadyDate": "2019-10-02 18:01:19",
"weight": 123
}
];
export const handleFilterModifier = (value, compareValue, modifier) => {
if (modifier === 'lessThan') {
return value > compareValue;
}
if (modifier === 'equals') {
return value === compareValue;
}
if (modifier === 'greaterThan') {
return value < compareValue;
}
return null;
};
const resultList = list.filter(
item => Object.entries(queryModifiers).every(([filterKey, filterVal]) => {
const compareValue = item[filterKey];
const value = Object.values(queryKeys);
const result = handleFilterModifier(
parseFloat(value),
compareValue,
filterVal
);
return result;
})
);
This operation fails when either of the queryModifiers has "equals" in its value pair. Anything else returns the actual true result. I don't understand why it fails on "equals".
I feel like there should be a forEach somewhere but I don't know where to put it and maybe there's something wrong with the code. I need help figuring it out.
I think you should replace this
const queryKeys = keys: {
price: '1000',
weight: '1000'
}
with
const queryKeys = {
price: '1000',
weight: '1000'
}
and replace this
const value = Object.values(queryKeys);
with
const value = queryKeys[filterKey];

Nested JSON parsing using JSONparse()

I cannot seem to extract the data I want from this (verified) JSON string coming from my home automation server (i.e. I cannot change the JSON return).
var myJson = '{ "Device_Num_6": { "states": [ { "id": 207, "service": "urn:upnp-org:serviceId:SwitchPower1", "variable": "Status", "value": "0" }, { "id": 208, "service": "urn:upnp-org:serviceId:Dimming1", "variable": "LoadLevelTarget", "value": "94" }, { "id": 209, "service": "urn:upnp-org:serviceId:Dimming1", "variable": "LoadLevelStatus", "value": "0" }, { "id": 210, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "Configured", "value": "1" }, { "id": 211, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "ModeSetting", "value": "1:;2:;3:;4:" }, { "id": 212, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "LastUpdate", "value": "1438440091" }, { "id": 213, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "FirstConfigured", "value": "1438440091" }, { "id": 214, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "Capabilities", "value": "209,140,0,4,17,1,L,R,RS,|38:1,39,112,114,115,134," }, { "id": 215, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ManufacturerInfo", "value": "99,17495,12848" }, { "id": 216, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "VersionInfo", "value": "6,1,91,2,11" }, { "id": 217, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "NodeInfo", "value": "26,27,70,72,73,86," }, { "id": 218, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "Neighbors", "value": "1,2,3,4,6,7,8,9,11,12,13,14,15,16,17,21,25,26,27,31,32,33,34,35," }, { "id": 219, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastReset", "value": "0" }, { "id": 220, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "AssociationNum", "value": "0" }, { "id": 221, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastRouteUpdate", "value": "1468760253" }, { "id": 222, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollOk", "value": "43947" }, { "id": 223, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastNnu", "value": "1468735200,700" }, { "id": 224, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastArr", "value": "1468735200,700" }, { "id": 225, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollNoReply", "value": "54" }, { "id": 226, "service": "urn:micasaverde-com:serviceId:ZWaveNetwork1", "variable": "ConsecutivePollFails", "value": "0" } ], "Jobs": [ ], "PendingJobs": 0, "tooltip": { "display": 0 }, "status": -1 }, "Using_2G": 0, "LoadTime": 1468766261, "DataVersion": 766262647, "UserData_DataVersion": 766261013, "TimeStamp": 1468779944, "lights_on": 3, "lights_off": 8, "doors_locked": 5, "doors_unlocked": 2, "sensors_tripped": 0, "sensors_not_tripped": 8, "failed_devices": 8, "visible_devices": 93, "partitions_active": 0, "partitions_notactive": 2, "alerts": [ { "PK_Device": 154, "Room": 10, "DeviceName": "Laundry Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742240051", "LocalDate": "2016-07-17 10:38:22", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 2, "LocalTimestamp": 1468766302, "Code": "SL_BATTERYALARM", "NewValue": "0", "Description": "Laundry Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 150, "Room": 23, "DeviceName": "Kids Bath Motion", "DeviceType": "urn:schemas-micasaverde-com:device:MotionSensor:1", "PK_Alert": "4742240181", "LocalDate": "2016-07-17 10:38:22", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 2, "LocalTimestamp": 1468766302, "Code": "SL_BATTERYALARM", "NewValue": "10", "Description": "Kids Bath Motion", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 101, "Room": 21, "DeviceName": "Cabana Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742255081", "LocalDate": "2016-07-17 10:40:18", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 2, "LocalTimestamp": 1468766418, "Code": "DL_LOW_BATTERY", "NewValue": "1", "Description": "Cabana Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 101, "Room": 21, "DeviceName": "Cabana Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742255231", "LocalDate": "2016-07-17 10:40:18", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 3, "LocalTimestamp": 1468766418, "Code": "DL_LOCK_CHANGED", "NewValue": "3", "Description": "Cabana Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 101, "Room": 21, "DeviceName": "Cabana Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742255371", "LocalDate": "2016-07-17 10:40:18", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 3, "LocalTimestamp": 1468766418, "Code": "DL_CODE_CHANGED", "NewValue": "3", "Description": "Cabana Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 101, "Room": 21, "DeviceName": "Cabana Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742255471", "LocalDate": "2016-07-17 10:40:18", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 3, "LocalTimestamp": 1468766418, "Code": "DL_USERCODE", "NewValue": "UserID=\"1\" UserName=\"Main\"", "Description": "Cabana Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 101, "Room": 21, "DeviceName": "Cabana Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742255591", "LocalDate": "2016-07-17 10:40:18", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 3, "LocalTimestamp": 1468766418, "Code": "DL_LOCK_BUTTON", "NewValue": "1", "Description": "Cabana Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 101, "Room": 21, "DeviceName": "Cabana Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742255721", "LocalDate": "2016-07-17 10:40:18", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 1, "LocalTimestamp": 1468766418, "Code": "DL_LOCK_FAILURE", "NewValue": "1", "Description": "Cabana Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 101, "Room": 21, "DeviceName": "Cabana Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742255801", "LocalDate": "2016-07-17 10:40:18", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 1, "LocalTimestamp": 1468766418, "Code": "DL_PINFAILED", "NewValue": "1", "Description": "Cabana Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" }, { "PK_Device": 101, "Room": 21, "DeviceName": "Cabana Door Lock", "DeviceType": "urn:schemas-micasaverde-com:device:DoorLock:1", "PK_Alert": "4742255971", "LocalDate": "2016-07-17 10:40:18", "EventType": 4, "SourceType": 4, "Argument": 0, "Filesize": 0, "Severity": 2, "LocalTimestamp": 1468766418, "Code": "SL_BATTERYALARM", "NewValue": "0", "Description": "Cabana Door Lock", "Users": "", "Server_Storage": "", "Key": "", "Icon": "", "PK_Store": "0" } ], "ZWaveStatus": 1, "Mode": 1, "LocalTime": "2016-07-17 14:25:44 D" }';
var myObject = JSON.parse(myJson);
console.log(myObject.Device_Num_6.states[0].id); // should return 207
Your json has invalid format. Because of that you couldn't to parse it as JSON.parse method. Try to check it here http://jsonviewer.stack.hu/
UPD: issue with this string "NewValue": "UserID=\"1\" UserName=\"Main\"". You should make it as "NewValue": "UserID=\\"1\\" UserName=\\"Main\\""

javascript for repeats in object [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
hey guys I have a problem :)
the result is wrong.I am filtering for personnal codes and dates. every personal has an array for it. You can see it from dateArr. in dateArr you can see 2 different arrays. these are two different personal actually. In vm.resReport there is dates for these personels I want to took the values of personnel that in vm.resREport and personnel code of it equal to dateArr's personnel. And put these values to dateArr
for(var item in vm.resReport){
for(var k=0;k < Object.keys(vm.dateArr).length;k++){
for(var days in vm.dateArr[k].Days){
if(vm.resReport[item].mDate==vm.dateArr[k].Days[days].FullDate){
for(var per in vm.resReport[item].Details){
if(vm.dateArr[k].PersonnelCode==vm.resReport[item].Details[per].PersonnelCode){
console.log(vm.resReport[item].Details[per].PersonnelFirstName);
vm.dateArr[k].Days[days].PersonnelCode=[];
vm.dateArr[k].Days[days].PersonnelCode[vm.dateArr[k].PersonnelCode]=vm.resReport[item].Details[per].PersonnelCode;
}
}
}
}
}
}
my problem is, in the second repeat. The for circle works actually but it repeats all together for whatever the k. but it needs to finilise the first k element than the other. but it just repeats all together.
How can I solve this? Thank you :) Cheers!
Edit: Here my Object
{
0:{Days:Array[30],PersonnelCode:"PRS_001" PersonnelFirstName:"Güvenc" PersonnelLastName:"Vural"},
1:{Days:Array[30],PersonnelCode:"PRS_111" PersonnelFirstName:"Timur" PersonnelLastName:"Hacizade"}
}
here my resReport Object;
[
{
"Total": 1,
"mDate": "2016-02-15",
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Total": 1,
"mDate": "2016-03-08",
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Total": 1,
"mDate": "2016-04-08",
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Total": 3,
"mDate": "2016-04-09",
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 2
},
{
"PersonnelFirstName": "Timur",
"PersonnelLastName": "Hacizade",
"PersonnelCode": "PRS_111",
"Total": 1
}
]
},
{
"Total": 1,
"mDate": "2016-04-13",
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Total": 1,
"mDate": "2016-04-14",
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
}
]
and here my dateArr Object
[
{
"PersonnelCode": "PRS_001",
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"Days": [
{
"Day": "01",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-01",
"ID": 92,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "02",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-02",
"ID": 93,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "03",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-03",
"ID": 94,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "04",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-04",
"ID": 95,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "05",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-05",
"ID": 96,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "06",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-06",
"ID": 97,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "07",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-07",
"ID": 98,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "08",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-08",
"ID": 99,
"StatusName": 1,
"Popover": false,
"Update": false,
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Day": "09",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-09",
"ID": 100,
"StatusName": 3,
"Popover": false,
"Update": false,
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 2
},
{
"PersonnelFirstName": "Timur",
"PersonnelLastName": "Hacizade",
"PersonnelCode": "PRS_111",
"Total": 1
}
]
},
{
"Day": 10,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-10",
"ID": 101,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 11,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-11",
"ID": 102,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 12,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-12",
"ID": 103,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 13,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-13",
"ID": 104,
"StatusName": 1,
"Popover": false,
"Update": false,
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Day": 14,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-14",
"ID": 105,
"StatusName": 1,
"Popover": false,
"Update": false,
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Day": 15,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-15",
"ID": 106,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 16,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-16",
"ID": 107,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 17,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-17",
"ID": 108,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 18,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-18",
"ID": 109,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 19,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-19",
"ID": 110,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 20,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-20",
"ID": 111,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 21,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-21",
"ID": 112,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 22,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-22",
"ID": 113,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 23,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-23",
"ID": 114,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 24,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-24",
"ID": 115,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 25,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-25",
"ID": 116,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 26,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-26",
"ID": 117,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 27,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-27",
"ID": 118,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 28,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-28",
"ID": 119,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 29,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-29",
"ID": 120,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 30,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-30",
"ID": 121,
"StatusName": "NA",
"Popover": false,
"Update": false
}
],
"Update": false
},
{
"PersonnelCode": "PRS_111",
"PersonnelFirstName": "Timur",
"PersonnelLastName": "Hacizade",
"Days": [
{
"Day": "01",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-01",
"ID": 92,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "02",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-02",
"ID": 93,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "03",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-03",
"ID": 94,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "04",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-04",
"ID": 95,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "05",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-05",
"ID": 96,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "06",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-06",
"ID": 97,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "07",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-07",
"ID": 98,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": "08",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-08",
"ID": 99,
"StatusName": 1,
"Popover": false,
"Update": false,
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Day": "09",
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-09",
"ID": 100,
"StatusName": 3,
"Popover": false,
"Update": false,
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 2
},
{
"PersonnelFirstName": "Timur",
"PersonnelLastName": "Hacizade",
"PersonnelCode": "PRS_111",
"Total": 1
}
]
},
{
"Day": 10,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-10",
"ID": 101,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 11,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-11",
"ID": 102,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 12,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-12",
"ID": 103,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 13,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-13",
"ID": 104,
"StatusName": 1,
"Popover": false,
"Update": false,
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Day": 14,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-14",
"ID": 105,
"StatusName": 1,
"Popover": false,
"Update": false,
"Details": [
{
"PersonnelFirstName": "Güvenc",
"PersonnelLastName": "Vural",
"PersonnelCode": "PRS_001",
"Total": 1
}
]
},
{
"Day": 15,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-15",
"ID": 106,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 16,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-16",
"ID": 107,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 17,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-17",
"ID": 108,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 18,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-18",
"ID": 109,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 19,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-19",
"ID": 110,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 20,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-20",
"ID": 111,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 21,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-21",
"ID": 112,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 22,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-22",
"ID": 113,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 23,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-23",
"ID": 114,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 24,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-24",
"ID": 115,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 25,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-25",
"ID": 116,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 26,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-26",
"ID": 117,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 27,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-27",
"ID": 118,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 28,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-28",
"ID": 119,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 29,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-29",
"ID": 120,
"StatusName": "NA",
"Popover": false,
"Update": false
},
{
"Day": 30,
"Cls": "",
"ClsStatus": "",
"FullDate": "2016-04-30",
"ID": 121,
"StatusName": "NA",
"Popover": false,
"Update": false
}
],
"Update": false
}
]
Please check the solution and tell me if it solved the problem.
for(var item in vm.resReport){
var report = vm.resReport[item];
for(var k=0;k < Object.keys(vm.dateArr).length;k++){
var dateInfo = vm.dateArr[k];
var days = dateInfo.Days;
for(var day in days){
var currDay = days[day];
if(report.mDate==currDay.FullDate){
for(var per in report.Details){
var detail = report.Details[per];
if(dateInfo.PersonnelCode==detail.PersonnelCode){
console.log(detail.PersonnelFirstName);
currDay.PersonnelCode=[];
currDay.PersonnelCode[dateInfo.PersonnelCode]=detail.PersonnelCode;
}
}
}
}
}
}
If you want all the k = 0 done before all the k = 1, and so on, you need to invert the nesting of the loops.
for(var k=0;k < Object.keys(vm.dateArr).length;k++){
for(var item in vm.resReport){
...
}
}

JSON hierarchy, how to get an element?

$("#loginsubmit").live("click", function() {
var request = new Request();
request.service = "http://88.80.223.163:8080/lumiin-service/lumiin/control/eventmap/1" ;
RequestHandler(request,displayData);
});
function displayData(data) {
//alert(data.contents.ownerId);
var cont = data.contents;
$("#mono").html(''+cont.id);
}
I am using the above code snippet to get the id, which works fine...How do I get the firstName?
Object:
{
"id": 1,
"eventId": {
"URL": "web",
"location": "web",
"url": "web",
"id": 54,
"type": {
"name": "Meeting",
"id": 1,
"isDeleted": "N",
"description": "Meeting"
},
"abteilung": {
"id": 165,
"code": "web123",
"isDeleted": null,
"domainId": 0,
"parentId": 164,
"description": null
},
"eventName": "Tanvi",
"place": "web",
"startDate": 1335830400000,
"endDate": 1337558400000,
"prospectId": null,
"person": "web",
"isDeleted": "N",
"countryId": {
"name": "CH",
"id": 1,
"isDeleted": "N",
"description": "Switzerland"
},
"followUp": null,
"budget": 0,
"description": "web"
},
"ownerId": {
"id": 67,
"firstName": "web123",
"localOrg": null,
"industryTypeId": null,
"memeber": false,
"profileType": "Manager",
"emailId": "web123",
"abteilung": {
"id": 165,
"code": "web123",
"isDeleted": null,
"domainId": 0,
"parentId": 164,
"description": null
},
"userCode": "web123",
"authenticatedAccess": -1,
"uuid": null,
"lastName": "web123",
"isDeleted": "N",
"passWord": "web123",
"fullName": "web123,web123",
"status": 0
},
"prospectId": {
"id": 303,
"firstName": "web123",
"emailId": "web123#gg.com",
"ownerId": {
"id": 67,
"firstName": "web123",
"localOrg": null,
"industryTypeId": null,
"memeber": false,
"profileType": "Manager",
"emailId": "web123",
"abteilung": {
"id": 165,
"code": "web123",
"isDeleted": null,
"domainId": 0,
"parentId": 164,
"description": null
},
"userCode": "web123",
"authenticatedAccess": -1,
"uuid": null,
"lastName": "web123",
"isDeleted": "N",
"passWord": "web123",
"fullName": "web123,web123",
"status": 0
},
"abteilung": {
"id": 165,
"code": "web123",
"isDeleted": null,
"domainId": 0,
"parentId": 164,
"description": null
},
"startDate": 1335744000000,
"endDate": 1337904000000,
"statusId": {
"name": "New",
"id": 1,
"isDeleted": "N",
"description": "New"
},
"company": "company",
"lastName": "web123",
"isDeleted": "N",
"yearofBirth": null,
"annualRevenue": 0,
"nationalityId": {
"name": "CH",
"id": 1,
"isDeleted": "N",
"description": "Switzerland"
},
"titleId": {
"name": "Mr",
"id": 1,
"isDeleted": "N",
"description": "Mr"
},
"maritalstatusId": null,
"residencyId": null,
"languageId": null,
"priorityId": {
"name": "Low",
"id": 1,
"isDeleted": "N",
"description": "Low"
},
"genderId": {
"name": "Male",
"id": 1,
"isDeleted": "N",
"description": "Male"
}
},
"isDeleted": "N"
}
The firstName is a property of the prospectId object you can read it in this way:
var firstName = data.prospectId.firstName;
var lastName = data.prospectId.lastName;
Fiddle

Categories