Given source data and destination data (in json format), write a function which will validate whether source data is same as destination data and highlight the differences.

19 views
Skip to first unread message

tal...@gmail.com

unread,
Aug 6, 2018, 8:16:00 AM8/6/18
to Django users

please do solve this quires asap....


Given source data and destination data (in json format), write a function which will validate whether
source data is same as destination data and highlight the differences.
Bonus: If you can validate order of data in list type values as well.

E.g. below source_data and destination data are not same (highlighted difference in bold )

source_data = {
"name": "Kaleigh",
"username": "Kaleigh60",
"email": "Kalei...@gmail.com",
"address": {
"street": "Myah Course",
"suite": "Apt. 657",
"city": "Boyerberg",
"zipcode": "66413-8920",
"geo": {
"lat": "-44.6203",
"lng": "16.7454"
}
},
"website": "megane.biz",
"friends": [
{
"name": "Little-Reinger",
"catchPhrase": "Enhanced regional emulation"
},
{
"name": "Big-Reinger",
"catchPhrase": "emulation"
}
],
"Numbers": [
1, 2, 3, 4
]
}
destination_data = {
"name": "Kaligh",
"username": "Kaleigh60",
"email": "Kalei...@gmail.com",
"address": {
"street": "Gold Course",
"suite": "Apt. 657",
"city": "Boyerberg",
"zipcode": "66413-8920",
"geo": {
"lat": "-44.6203",
"lng": "16.7454"
}
},
"website": "megane.biz",
"friends": [
{
"name": "Reinger",
"catchPhrase": "Enhanced regional emulation"
},
{
"name": "Big-Reinger",
"catchPhrase": "emulation"
}
],
"Numbers": [
4, 2, 1, 5
]
}
E.g 2. Following data are same
source_data = {
"name": "Kaleigh",
"username": "Kaleigh60",
"email": "Kalei...@gmail.com",
"address": {
"street": "Myah Course",
"suite": "Apt. 657",
"city": "Boyerberg",
"zipcode": "66413-8920",
"geo": {
"lat": "-44.6203",
"lng": "16.7454"
}
}
}
destination_data = {
"name": "Kaleigh",
"address": {
"street": "Myah Course",
"suite": "Apt. 657",
"city": "Boyerberg",
"zipcode": "66413-8920",
"geo": {
"lat": "-44.6203",
"lng": "16.7454"
}
},
"username": "Kaleigh60",
"email": "Kalei...@gmail.com",
}

Derek

unread,
Aug 7, 2018, 6:17:51 AM8/7/18
to Django users
This is not a Django issue; try and post on a Python mailing list.

(HINT: if you want help with code, then write a function that shows what you have attempted.  No one else will actually write your code for you...)
Reply all
Reply to author
Forward
0 new messages