简体   繁体   中英

Merging Two Json Files using JQ

I have two json files that I would like to merge using jq in order to pass to AWS Lambda as a payload.

File 1

 {
    "Product": {
      "name": "Foo"
      "description": "bar",
     }
}

File 2

 {
    "Store": {
      "id": "123"
      "location": "abc",
     }
}

My desired output:

 {
    "Product": {
      "name": "Foo"
      "description": "bar",
     },
    "Store": {
      "id": "123"
      "location": "abc",
     }
}

I know I can do jq -s. File1 File2 jq -s. File1 File2 , but this puts it into an array - is there a way to do this merge without putting the two files into an array?

This seemed to work jq -s '.[0] *.[1]' File1 File2 jq -s '.[0] *.[1]' File1 File2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM