TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Adhikar Patil
NA
481
128.3k
How to combine json's in angular 8
Mar 15 2020 12:16 PM
Hello,
I have three json into array like and also i want array[0] with the first json including other jsons nonmatching key with blank value. Please provide me the solution in angular 8
json1 = {name: "Adhikar", email: "
[email protected]
", phoneNumber: "(898) 990-9090", cropType: "rawCrop", cropName: {jawar: true, bajri: false}, cropPeriod: 120}
json2 = {name: "Sagar", email: "
[email protected]
", phoneNumber: "", cropType: "", phvalue: 90 }
json3 = {name: "Ajay", email: "
[email protected]
", phoneNumber: "", cropType: "rawCrop", cropWeather: "winter"}
so i want to update my array[0] Like this
json1 = {name: "Adhikar", email: "
[email protected]
", phoneNumber: "(898) 990-9090", cropType: "rawCrop", cropName: {jawar: true, bajri: false}, cropPeriod: 120, phvalue:"", cropWeather: ""}
json2 = {name: "Sagar", email: "
[email protected]
", phoneNumber: "", cropType: "", phvalue: 90 }
json3 = {name: "Ajay", email: "
[email protected]
", phoneNumber: "", cropType: "rawCrop", cropWeather: "winter"}
Here is my code, please see the code
getDynamicFormData() {
this.dynamicFormResponseService.get(this.id).subscribe(
res => {
if (res && res != null) {
this.dynamicFormData = res;
const array = [];
const ids = [];
this.dynamicFormData.forEach(function (item) {
if (array[0] == null) {
array.push(JSON.parse(item.response));
}
else {
var mainArray = JSON.stringify(array[0]);
for (let key in JSON.parse(mainArray)) {
if (JSON.parse(mainArray).hasOwnProperty(key) == JSON.parse(item.response).hasOwnProperty(key)) {
}
}
console.log(array);
array.push(JSON.parse(item.response));
ids.push(item.id);
}
});
this.dynamicFormResponses = array;
this.dynamicFormResponsesId = ids;
}
},
error => {
this.toastr.error(error.message);
}
);
}
Reply
Answers (
3
)
Write a try catch block and print the exception message to t
How to show Angular project errors with a chrome extension