These are the two json files i have JSON1.json
{
"name": "HOSTNAME1",
"chef_environment": "non_prod",
"run_list": [
"role[MyOrg-non_prod]",
"role[rhel7-latest]",
"role[middleware-nonprod-all]",
"role[MyApp-middleware_corebase_prod]",
"role[MyApp_envs-test]",
"role[MyApp_envs-dev]",
"role[MyApp_nfs_mount]",
"role[MyApp_access-dev]",
"role[MyOrg-client-wrapper]"
]
}
JSON2.json
{
"name": "HOSTNAME2",
"chef_environment": "non_prod",
"run_list": [
"role[MyOrg-non_prod]",
"role[rhel7-latest]",
"role[MyApp_unix_app-dev]",
"role[MyApp_middleware_corebase_prod]"
]
}
These files may or may not be sorted. I need to get the unique values of JSON2 which are not available in JSON1
I have initially tried it using commands like
findstr /vig:JSON1.json JSON2.json | grep -v name| grep -e MyApp -e MyOrg | tr -d '\n'| sed -e 's:"::g' -e 's: *::g' -e 's:,$::'
However this dosent work, consider for example In JSON1 i have an entry "role[MyApp_middleware_corebase_prod]",
and in JSON2 "role[MyApp_middleware_corebase_prod]"
Note the difference in comma, although the entry is same and hence not unique, however due to presence of comma this is considered as unique and gives me an undesired output.
If i compare JSON1 vs JSON2 the expected output is role[MyApp_unix_app-dev] as this is ONLY unique to JSON2
And if i compare JSON2 vs JSON1
role[MyApp_envs-test],role[MyApp_envs-dev],role[MyApp_nfs_mount],role[MyApp_access-dev],role[MyOrg-client-wrapper]