I have multiple JSON strings, which are stored in my database.
Here are 3 example of how they could look like:
Example 1
{
"request": {
"city": "Chicago",
"country": "USA",
"gender": "m"
}
}
Example 2
{
"request": {
"city": "Chicago",
"country": "USA",
"gender": "f",
"role": "admin"
}
}
Example 3
{
"request": {
"city": "Paris",
"country": "France",
"gender": "m",
"language": "French",
"role": "admin"
}
}
I would like to compare all JSONs with each other and create a new JSON with the most listed values. This is how the result should be:
Result
{
"request": {
"city": "Chicago",
"country": "USA",
"gender": "m",
"role": "admin"
}
}
Why?
Because we had 3 JSONS and
Chicago
appeared 2xUSA
appeared 2xm
appeard 2xadmin
appeared 2x
How can I get that JSON that I need?
PS: I don't need a finished code. It's enough if someone could explain me HOW I could do it.