I'd like to compare two or more APIs, and outputting the common records found according to one of the fields.
For instance, given this API:
https://belgianrefugees.leeds.ac.uk/wp-json/brdb/v1/entries
I'd like to compare it with another similar one, which might have different fields, although it certainly have a 'full name' field, as in the first one.
I'm happy to get the JSON of the data I want to compare and run everything from my local machine: this is just a proof of concept and test, I'm not developing a finite product.
I've seen this and since it's dated now and it doesn't do exactly what I want, I'm posting this question. Any language/framework is fine by me. Thanks in advance.
Example:
First JSON:
{
"entry_id": "460",
"Surname": "Embrechts",
"Name": "Karl",
"Sex": "F",
"Occupation": "Farmer"
},
Second JSON:
{
"entry_id": "460",
"Surname": "Embrechts",
"Name": "Karl",
"Full Name": "Karl Embrechts"
"Sex": "M",
"Married": "Yes"
"Job": "Photographer"
},
I want to be able to spot these two record which regard the same person via the fields 'Surname' and 'Name'.
Get the values with ajax. Convert them into objects with JSON.Parse() . Assuming it will be array of values so you will have 2 arrays. Iterate both arrays and compare properties you already know they exist on both side like this :
var isTheSame = value1["Name"] === value2["Name"] && value1["SurName"] === value2["SurName"];