Is there an easy way in javascript (running on nodejs) to merge various attributes of an object in an array? I know I can do it using some for loops etc, but was wondering if there is any easier way. My array of objects is like this -
[
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-07-04"
},
"AmazonCategoryRank": {
"category_name": "Tom",
"category_rank": 78,
"date_of_extraction": "2020-07-04"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-07-04"
},
"AmazonCategoryRank": {
"category_name": "Dick",
"category_rank": 103,
"date_of_extraction": "2020-07-04"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-07-04"
},
"AmazonCategoryRank": {
"category_name": "Harry",
"category_rank": 267,
"date_of_extraction": "2020-07-04"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-04-20"
},
"AmazonCategoryRank": {
"category_name": "Tom",
"category_rank": 42,
"date_of_extraction": "2020-04-20"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-04-20"
},
"AmazonCategoryRank": {
"category_name": "Dick",
"category_rank": 60,
"date_of_extraction": "2020-04-20"
}
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-04-20"
},
"AmazonCategoryRank": {
"category_name": "Harry",
"category_rank": 132,
"date_of_extraction": "2020-04-20"
}
}
]
And I would like them to be merged like this based on date_of_extraction
[
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-07-04"
},
"AmazonCategoryRank":[
{
"category_name": "Tom",
"category_rank": 78,
"date_of_extraction": "2020-07-04"
},
{
"category_name": "Dick",
"category_rank": 103,
"date_of_extraction": "2020-07-04"
},
{
"category_name": "Harry",
"category_rank": 267,
"date_of_extraction": "2020-07-04"
}
]
},
{
"asin": "123456",
"isbn": "09876543",
"title": "Joe bloggs",
"country": "us",
"published_date": "2019-07-30",
"AmazonProductPageInfo": {
"id": 1108,
"title_asin": "123456",
"country": "us",
"date_of_extraction": "2020-04-20"
},
"AmazonCategoryRank": [
{
"category_name": "Tom",
"category_rank": 42,
"date_of_extraction": "2020-04-20"
},
{
"category_name": "Dick",
"category_rank": 60,
"date_of_extraction": "2020-04-20"
},
{
"category_name": "Harry",
"category_rank": 132,
"date_of_extraction": "2020-04-20"
}
]
}
]
There is a good npm package called deepmerge looking at it might solve your problem.
You can do this in code via loops or just with functions such as Array.prototype.reduce in code of course.
If you're looking for a totally different way, databases are also quite good at grouping data. I'm doing something similar using mongodb-memory-server where I am making a temporary collection then streaming a large set of raw data into it and then using mongo aggregate pipelines to do the transformation work.
In this case for you, assuming you stream your sample records into a collection, your query may look something like this:
db.test.aggregate([
{
$group: {
_id: "$AmazonProductPageInfo.date_of_extraction",
asin: { $first: "$asin" },
isbn: { $first: "$isbn" },
title: { $first: "$title" },
country: { $first: "$country" },
published_date: { $first: "$published_date" },
AmazonProductPageInfo: { $first: "$AmazonProductPageInfo" },
AmazonCategoryRank: { $push: "$AmazonCategoryRank" }, // $push here
}
}
])
Where you use $first to pick the first scalar value for each field of the group, assuming they are all the same and use $push for the category rank objects which are distinct per group. That should give you your desired results.
You can then use a cursor to iterate over them all or do further transformations or aggregations in the same pipeline.
Related
I'm using the following FedEx sandbox API
https://apis-sandbox.fedex.com/ship/v1/shipments
and able to get the response which contains the tracking number.
But when I'm using that tracking number in the
https://apis-sandbox.fedex.com/track/v1/trackingnumbers
API getting the following error as TRACKING.TRACKINGNUMBER.NOTFOUND.
{
"transactionId": "b06f2eb2-8cdf-4139-83b7-1a6eccffed56",
"output": {
"completeTrackResults": [
{
"trackingNumber": "794693611559",
"trackResults": [
{
"trackingNumberInfo": {
"trackingNumber": "794693611559",
"trackingNumberUniqueId": "",
"carrierCode": ""
},
"error": {
"code": "TRACKING.TRACKINGNUMBER.NOTFOUND",
"message": "Tracking number cannot be found. Please correct the tracking number and try again."
}
}
]
}
]
}
}
But when I'm using the Mock tracking numbers provided by the FedEx for testing able to get the following response.
{
"transactionId": "3b56ae53-83fa-47f5-83d6-ec1ca6aeff3a",
"output": {
"completeTrackResults": [
{
"trackingNumber": "449044304137821",
"trackResults": [
{
"trackingNumberInfo": {
"trackingNumber": "449044304137821",
"trackingNumberUniqueId": "12013~449044304137821~FDEG",
"carrierCode": "FDXG"
},
"additionalTrackingInfo": {
"nickname": "",
"packageIdentifiers": [
{
"type": "GROUND_SHIPMENT_ID",
"values": [
"DMWsGWdnN"
],
"trackingNumberUniqueId": "",
"carrierCode": ""
},
{
"type": "CUSTOMER_REFERENCE",
"values": [
"115380173"
],
"trackingNumberUniqueId": "",
"carrierCode": ""
}
],
"hasAssociatedShipments": false
},
"shipperInformation": {
"address": {
"city": "JEFFERSONVILLE",
"stateOrProvinceCode": "IN",
"countryCode": "US",
"residential": false,
"countryName": "United States"
}
},
"recipientInformation": {
"address": {
"city": "Miami",
"stateOrProvinceCode": "FL",
"countryCode": "US",
"residential": false,
"countryName": "United States"
}
},
"latestStatusDetail": {
"code": "OC",
"derivedCode": "IN",
"statusByLocale": "Initiated",
"description": "Shipment information sent to FedEx",
"scanLocation": {
"city": "Miami",
"stateOrProvinceCode": "FL",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"ancillaryDetails": [
{
"reason": "IN001",
"reasonDescription": "Please check back later for shipment status or subscribe for e-mail notifications",
"action": "",
"actionDescription": ""
}
]
},
"dateAndTimes": [
{
"type": "ACTUAL_PICKUP",
"dateTime": "2016-08-01T00:00:00-06:00"
},
{
"type": "SHIP",
"dateTime": "2020-08-15T00:00:00-06:00"
}
],
"availableImages": [],
"packageDetails": {
"packagingDescription": {
"type": "YOUR_PACKAGING",
"description": "Package"
},
"physicalPackagingType": "PACKAGE",
"sequenceNumber": "1",
"count": "1",
"weightAndDimensions": {
"weight": [
{
"value": "3.0",
"unit": "LB"
},
{
"value": "1.36",
"unit": "KG"
}
],
"dimensions": [
{
"length": 14,
"width": 11,
"height": 5,
"units": "IN"
},
{
"length": 35,
"width": 27,
"height": 12,
"units": "CM"
}
]
},
"packageContent": []
},
"shipmentDetails": {
"possessionStatus": true
},
"scanEvents": [
{
"date": "2013-12-30T13:24:00-05:00",
"eventType": "OC",
"eventDescription": "Shipment information sent to FedEx",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"postalCode": "471307761",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationType": "CUSTOMER",
"derivedStatusCode": "IN",
"derivedStatus": "Initiated"
}
],
"availableNotifications": [],
"deliveryDetails": {
"deliveryAttempts": "0",
"deliveryOptionEligibilityDetails": [
{
"option": "INDIRECT_SIGNATURE_RELEASE",
"eligibility": "INELIGIBLE"
},
{
"option": "REDIRECT_TO_HOLD_AT_LOCATION",
"eligibility": "INELIGIBLE"
},
{
"option": "REROUTE",
"eligibility": "INELIGIBLE"
},
{
"option": "RESCHEDULE",
"eligibility": "INELIGIBLE"
},
{
"option": "RETURN_TO_SHIPPER",
"eligibility": "INELIGIBLE"
},
{
"option": "DISPUTE_DELIVERY",
"eligibility": "INELIGIBLE"
},
{
"option": "SUPPLEMENT_ADDRESS",
"eligibility": "INELIGIBLE"
}
],
"destinationServiceArea": "OC"
},
"originLocation": {
"locationContactAndAddress": {
"address": {
"city": "JEFFERSONVILLE",
"stateOrProvinceCode": "IN",
"countryCode": "US",
"residential": false,
"countryName": "United States"
}
}
},
"lastUpdatedDestinationAddress": {
"city": "Miami",
"stateOrProvinceCode": "FL",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"serviceCommitMessage": {
"message": "The delivery date may be updated when FedEx receives the package.",
"type": "SHIPMENT_LABEL_CREATED"
},
"serviceDetail": {
"type": "GROUND_HOME_DELIVERY",
"description": "FedEx Home Delivery",
"shortDescription": "HD"
},
"standardTransitTimeWindow": {
"window": {
"ends": "2014-01-02T00:00:00-06:00"
}
},
"estimatedDeliveryTimeWindow": {
"window": {}
},
"goodsClassificationCode": "",
"returnDetail": {}
}
]
}
]
}
}
Please help me with this, Thanks in advance.
Have you tried with a different real tracking number? Sometimes after sending a package, it takes a couple of hours for couriers such as FedEx and others update the tracking number...
This is the structure of my collection of mongodb database. I need to update the status inside each order products. What I need to do?
{
"_id": {
"$oid": "633ab3c11e6e97b6332f56a1"
},
"orders": [
{
"date": "6/10/2022",
"productDetails": {
"0": {
"name": "Top",
"price": "1235",
"quantity": 1,
"status": "placed"
},
"1": {
"name": "Shirt",
"price": "1235",
"quantity": 1,
"status": "placed"
}
},
"billingAddress": {
"address": "My Address",
"city": "City",
"state": "State",
"country": "Country",
"pincode": "123456",
"contact": "1234567890"
},
"paymentMode": "cod"
},
{
"date": "6/10/2022",
"productDetails": {
"0": {
"name": "Top",
"price": "1235",
"quantity": 3,
"status": "placed"
},
"1": {
"name": "Shirt",
"price": "1235",
"quantity": 1,
"status": "placed"
}
},
"billingAddress": {
"address": "My Address",
"city": "City",
"state": "State",
"country": "Country",
"pincode": "123456",
"contact": "1234567890"
},
"paymentMode": "cod"
},
{
"date": "6/10/2022",
"productDetails": {
"0": {
"name": "Shirt",
"price": "234",
"quantity": 1,
"status": "placed"
},
"1": {
"name": "Top",
"price": "123",
"quantity": 1,
"status": "placed"
}
},
"billingAddress": {
"address": "My Address",
"city": "City",
"state": "State",
"country": "Country",
"pincode": "123456",
"contact": "1234567890"
},
"paymentMode": "cod"
}
]
}
I want to update the order product status to shipped, canceled, etc. I have to set status in desired position like the following.
I waant to update the mongodb databse and have to get the result in like the following result.
{
"_id": {
"$oid": "633ab3c11e6e97b6332f56a1"
},
"orders": [
{
"date": "6/10/2022",
"productDetails": {
"0": {
"name": "Top",
"price": "1235",
"quantity": 1,
"status": "caneled"
},
"1": {
"name": "Shirt",
"price": "1235",
"quantity": 1,
"status": "shipped"
}
},
"billingAddress": {
"address": "My Address",
"city": "City",
"state": "State",
"country": "Country",
"pincode": "123456",
"contact": "1234567890"
},
"paymentMode": "cod"
},
{
"date": "6/10/2022",
"productDetails": {
"0": {
"name": "Top",
"price": "1235",
"quantity": 3,
"status": "canceled"
},
"1": {
"name": "Shirt",
"price": "1235",
"quantity": 1,
"status": "shipped"
}
},
"billingAddress": {
"address": "My Address",
"city": "City",
"state": "State",
"country": "Country",
"pincode": "123456",
"contact": "1234567890"
},
"paymentMode": "cod"
},
{
"date": "6/10/2022",
"productDetails": {
"0": {
"name": "Shirt",
"price": "234",
"quantity": 1,
"status": "placed"
},
"1": {
"name": "Top",
"price": "123",
"quantity": 1,
"status": "shipped"
}
},
"billingAddress": {
"address": "My Address",
"city": "City",
"state": "State",
"country": "Country",
"pincode": "123456",
"contact": "1234567890"
},
"paymentMode": "cod"
}
]
}
According to my research, the correct method is as follows:
db.orders.updateOne({_id: ObjectId("633a6a73dd9f8cce0029e53d")},{$set:{"orders.0.productDetails.0.status": "shipped"}})
And the result is :-
{
"_id": {
"$oid": "633ab3c11e6e97b6332f56a1"
},
"orders": [
{
"_id": {
"$oid": "633e8f2d3e3f12f07438cc64"
},
"date": "6/10/2022",
"productDetails": {
"0": {
"name": "Top",
"price": "1235",
"quantity": 1,
"status": "shipped"
},
"1": {
"name": "Shirt",
"price": "1235",
"quantity": 1,
"status": "placed"
}
},
"billingAddress": {
"address": "My Address",
"city": "City",
"state": "State",
"country": "Country",
"pincode": "123456",
"contact": "1234567890"
},
"paymentMode": "cod"
},
{
"_id": {
"$oid": "633e96533e3f12f07438cc65"
},
"date": "6/10/2022",
"productDetails": {
"0": {
"name": "Top",
"price": "1235",
"quantity": 1,
"status": "placed"
},
"1": {
"name": "Shirt",
"price": "1235",
"quantity": 1,
"status": "placed"
},
"2": {
"name": "Jeans",
"price": "1234",
"quantity": 1,
"status": "placed"
}
},
"billingAddress": {
"address": "My Address",
"city": "City",
"state": "State",
"country": "Country",
"pincode": "123456",
"contact": "1234567890"
},
"paymentMode": "cod"
}
]
}
PayPal Checkout
offers a JavaScript function to display buttons example:
<script>
paypal.Buttons({
createOrder: function(data, actions) {
// Set up the transaction
return actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
}
}).render('#paypal-button-container');
</script>
As you see, the Buttons function has an object as a parameter. Where can I see all the available properties of this object?
Check https://developer.paypal.com/docs/api/orders/v2/#orders_create
Request body section contains all the data that can be passed.
You can find it on the source code: https://github.com/paypal/paypal-checkout-components/blob/master/docs/implement-checkout.md
Here's a full list of everything you need
"purchase_units": [
{
"reference_id": "store_mobile_world_order_1234",
"description": "Mobile World Store order-1234",
"amount": {
"currency": "USD",
"details": {
"subtotal": "1.09",
"shipping": "0.02",
"tax": "0.33"
},
"total": "1.44"
},
"payee": {
"email": "seller#example.com"
},
"items": [
{
"name": "NeoPhone",
"sku": "sku03",
"price": "0.54",
"currency": "USD",
"quantity": "1"
},{
"name": "Fitness Watch",
"sku": "sku04",
"price": "0.55",
"currency": "USD",
"quantity": "1"
}
],
"shipping_address": {
"line1": "2211 N First Street",
"line2": "Building 17",
"city": "San Jose",
"country_code": "US",
"postal_code": "95131",
"state": "CA",
"phone": "(123) 456-7890"
},
"shipping_method": "United Postal Service",
"partner_fee_details": {
"receiver": {
"email": "partner#example.com"
},
"amount": {
"value": "0.01",
"currency": "USD"
}
},
"payment_linked_group": 1,
"custom": "custom_value_2388",
"invoice_number": "invoice_number_2388","payment_descriptor": "Payment Mobile World"
}
],
"redirect_urls": {
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel"
}
}'
I'm not sure the best way to go about this. I want to iterate my json and find all companies that are in the US for example. This JSON might get way more complex as my app grows too, as in levels, objects, etc. I just want to know ways people are doing simple searching for filtering out subsets of data with JSON and Node.js and/or ES6 or libraries maybe such as Lodash, etc.
So for example this json, what are some ways I can search it and pull back only those companies in the USA?
[{
"id": 0,
"name": "Company1",
"logoUrl": "/lib/assets/company1-logo.png",
"location":{
"country": "USA",
"state": "California",
"city": "Napa"
},
"active": false
},
{
"id": 1,
"name": "Company2",
"logoUrl": "/lib/assets/company2-logo.png",
"location":{
"country": "Germany",
"state": "",
"city": "Berlin"
},
"active": false
},
{
"id": 2,
"name": "Company3",
"logoUrl": "/lib/assets/company3-logo.png",
"location":{
"country": "USA",
"state": "Michigan",
"city": "Detroit"
},
"active": false
}]
Use JavaScript native Array#filter method with ES6 arrow function
var res = data.filter(v => v.location.country === 'USA');
var data = [{
"id": 0,
"name": "Company1",
"logoUrl": "/lib/assets/company1-logo.png",
"location": {
"country": "USA",
"state": "California",
"city": "Napa"
},
"active": false
}, {
"id": 1,
"name": "Company2",
"logoUrl": "/lib/assets/company2-logo.png",
"location": {
"country": "Germany",
"state": "",
"city": "Berlin"
},
"active": false
}, {
"id": 2,
"name": "Company3",
"logoUrl": "/lib/assets/company3-logo.png",
"location": {
"country": "USA",
"state": "Michigan",
"city": "Detroit"
},
"active": false
}];
var res = data.filter(v => v.location.country === 'USA');
console.log(res);
You can use JavaScript's simple .filter() method to return the list of results fulfilling the filter. Say your data is in variable data
ES5
data.filter(function(item) {
return item.location.country === 'USA';
});
ES6: In ES6 you can use arrow functions for same as
data.filter((item) => {
return item.location.country === 'USA';
});
var data = [{
"id": 0,
"name": "Company1",
"logoUrl": "/lib/assets/company1-logo.png",
"location":{
"country": "USA",
"state": "California",
"city": "Napa"
},
"active": false
},
{
"id": 1,
"name": "Company2",
"logoUrl": "/lib/assets/company2-logo.png",
"location":{
"country": "Germany",
"state": "",
"city": "Berlin"
},
"active": false
},
{
"id": 2,
"name": "Company3",
"logoUrl": "/lib/assets/company3-logo.png",
"location":{
"country": "USA",
"state": "Michigan",
"city": "Detroit"
},
"active": false
}];
var res1 = data.filter(function(item) {
return item.location.country === 'USA';
});
const res2 = data.filter((item) => {
return item.location.country === 'USA';
});
console.log(res1);
console.log(res2);
In lodash it will be
_.filter(data, function(item) {
return item.location.country === 'USA';
});
You can use native filter function.
const items = [{
"id": 0,
"name": "Company1",
"logoUrl": "/lib/assets/company1-logo.png",
"location":{
"country": "USA",
"state": "California",
"city": "Napa"
},
"active": false
},
{
"id": 1,
"name": "Company2",
"logoUrl": "/lib/assets/company2-logo.png",
"location":{
"country": "Germany",
"state": "",
"city": "Berlin"
},
"active": false
},
{
"id": 2,
"name": "Company3",
"logoUrl": "/lib/assets/company3-logo.png",
"location":{
"country": "USA",
"state": "Michigan",
"city": "Detroit"
},
"active": false
}]
const usItems = items.filter(v => v.location.country === 'USA')
I have a situation where I'm getting list of complex JSON data(nested type).I'm new to AngularJS, not getting solution to run ng-repeat or forEach over that.
My returned data is like below.
[{
"studPersonalDetails": {
"id": 0,
"name": "Digvijay",
"middleName": "",
"lastName": "Singh",
"fatherName": "abac",
"motherName": "abc",
"dob": "5/7/1990 12:00:00 AM"
},
"clients": {
"clientID": 1,
"clientName": null,
"clientDescriptions": null
},
"studentAddress": {
"address1": "12",
"address2": "12",
"city": "21",
"state": "212",
"pin": 2
},
"courseDetails": {
"courseID": 12,
"courseName": "12",
"courseDetail": null
},
"studentContacts": {
"email": "12",
"alternatePhone": "12",
"phone": "qw"
}
}, {
"studPersonalDetails": {
"id": 0,
"name": "Anil",
"middleName": "kumar",
"lastName": "Sharma",
"fatherName": "bac",
"motherName": "bac",
"dob": "2/11/1989 12:00:00 AM"
},
"clients": {
"clientID": 1,
"clientName": null,
"clientDescriptions": null
},
"studentAddress": {
"address1": "21",
"address2": "21",
"city": "5456",
"state": "8",
"pin": 7
},
"courseDetails": {
"courseID": 58,
"courseName": "58",
"courseDetail": null
},
"studentContacts": {
"email": "12",
"alternatePhone": "12",
"phone": "abc"
}
}]
This is the response returned by API.
Any help would be appreciated!Thanks!!
You can try something like this:
JSFiddle.
<div ng-repeat="currentRow in data">
<span>{{currentRow.studPersonalDetails.name}}</span>
<span>{{currentRow.studPersonalDetails.lastName}}</span>
</div>
$scope.arr = [{
"studPersonalDetails": {
"id": 0,
"name": "Digvijay",
"middleName": "",
"lastName": "Singh",
"fatherName": "Shyam Bahadur Singh",
"motherName": "ramawati Devi",
"dob": "5/7/1990 12:00:00 AM"
},
"clients": {
"clientID": 1,
"clientName": null,
"clientDescriptions": null
},
"studentAddress": {
"address1": "12",
"address2": "12",
"city": "21",
"state": "212",
"pin": 2
},
"courseDetails": {
"courseID": 12,
"courseName": "12",
"courseDetail": null
},
"studentContacts": {
"email": "12",
"alternatePhone": "12",
"phone": "qw"
}
}, {
"studPersonalDetails": {
"id": 0,
"name": "Anil",
"middleName": "kumar",
"lastName": "Sharma",
"fatherName": "bac",
"motherName": "bac",
"dob": "2/11/1989 12:00:00 AM"
},
"clients": {
"clientID": 1,
"clientName": null,
"clientDescriptions": null
},
"studentAddress": {
"address1": "21",
"address2": "21",
"city": "5456",
"state": "8",
"pin": 7
},
"courseDetails": {
"courseID": 58,
"courseName": "58",
"courseDetail": null
},
"studentContacts": {
"email": "12",
"alternatePhone": "12",
"phone": "abc"
}
}]
Using angular.forEach you can do it like this.
angular.forEach($scope.arr,function(value,key){
console.log(value.studPersonalDetails.lastName);
})
Using ng-repeat,you can do it like this.
<tr ng-repeat="oneArr in arr">
<td> {{oneArr.studPersonalDetails.name}}</td>
</tr>
Here is the plunker
You can see an angular ngRepeat example with your data here
First, create a controller with your data:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.datalist = [
{
"studPersonalDetails":{
"id":0,
"name":"Digvijay",
"middleName":"",
"lastName":"Singh",
"fatherName":"Shyam Bahadur Singh",
"motherName":"ramawati Devi",
"dob":"5/7/1990 12:00:00 AM"
},
"clients":{
"clientID":1,
"clientName":null,
"clientDescriptions":null
},
"studentAddress":{
"address1":"12",
"address2":"12",
"city":"21",
"state":"212",
"pin":2
},
"courseDetails":{
"courseID":12,
"courseName":"12",
"courseDetail":null
},
"studentContacts":{
"email":"12",
"alternatePhone":"12",
"phone":"qw"
}
},
{
"studPersonalDetails":{
"id":0,
"name":"Anil",
"middleName":"kumar",
"lastName":"Sharma",
"fatherName":"bac",
"motherName":"bac",
"dob":"2/11/1989 12:00:00 AM"
},
"clients":{
"clientID":1,
"clientName":null,
"clientDescriptions":null
},
"studentAddress":{
"address1":"21",
"address2":"21",
"city":"5456",
"state":"8",
"pin":7
},
"courseDetails":{
"courseID":58,
"courseName":"58",
"courseDetail":null
},
"studentContacts":{
"email":"12",
"alternatePhone":"12",
"phone":"abc"
}
}
];
}
Then attach this controller to your view and use the ngRepeat to extract each top-level object from dataList array (during the itaration the current object has alias data)
Inside the repeat statement you can display requested values accessing the data object using dot notation:
<div ng-controller="MyCtrl">
<div class="row" ng-repeat="data in datalist">
<p><span>Name</span> {{ data.studPersonalDetails.name }}</p>
<p><span>CourseID</span> {{ data.courseDetails.courseID }}</p>
</div>
</div>