I have two data sources that I retrieve different format Json's from and I want to create a normalized object that will represent the merged Json's according to distinct values.
For example, the first json:
[
{
"zone_group": "us-east-1b",
"kernel_version": "5.10.130-118.517.amzn2.x86_64",
"chassis_type": "1",
"chassis_type_desc": "Other",
"connection_ip": "172.xx.xx.xx",
"default_gateway_ip": "172.xx.xx.xx",
"connection_mac_address": "12-5e-2e-db-xx-xx"
...
}
]
the second json:
[
{
"sourceInfo": {
"list": [
{
"Ec2AssetSourceSimple": {
"instanceType": "t2.micro",
"groupName": "AutoScaling-Group-1",
"macAddress": "12-5e-2e-db-xx-xx",
"monitoringEnabled": "false",
"spotInstance": "false",
"zone": "VPC",
"instanceState": "RUNNING",
"type": "EC_2",
"availabilityZone": "us-east-1b",
"privateIpAddress": "172.xx.xx.xx",
"firstDiscovered": "2022-08-18T22:23:04Z"
...
}
]
I want to normalize the Json's and create a unified representation of them based on values, in this example the IP address "172.xx.xx.xx" will be represented once in the normalized object (name taken from the first Json, but doesn't really matter).
How do I go about and do this?
IIUC:
Code:
Output: