Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 608

With jq Intersection of 2 json objects

$
0
0

I have a first json structure.All the values are always null.

{"A": {"A1": {"A11": null,"A12": null        }    },"B": {"B1": {"B12": null        },"B2": null    },"C": {"C1": {"C11": null,"C12": null        },"C2" : {"C21": {"C211": null            }        }    }}

In the second json structure, all the values are always strings.

{"A": {"A1": {"A11": "valueA11",        }    },"B": {"B1": {"B12": "valueB12","B13": "valueB13"        },"B2": "valueB2"    },"C": "valueC"}

The result would be :

{"A": {"A1": {"A11": "valueA11","A12": null        }    },"B": {"B1": {"B12": "valueB12"        },"B2": "valueB2"    },"C": {"C1": {"C11": null,"C12": null        },"C2" : {"C21": {"C211": null            }        }    }}

How do I fill the first json keys with values from the second if the keys exists in the second json, otherwise we keep the null values

I've tried with jq on bash but without success. I'm ready to use whatever tool that makes the job.


Viewing all articles
Browse latest Browse all 608

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>