title: Find json object by key and replace it with other object from complex/nested json array
body: <p>I'm trying to find json object by a property/key from a complex/nested json array and replace it with other json object in an angular project. </p>
  
  <p>I have used lodash to find json object by key but the json path of object can be anywhere on json array.</p>
  
  <p><strong>Here is my sample json array:</strong></p>
  
  <pre><code>{
    "type": "form",
    "title": "title",
    "name": "name",
    "display": "form",
    "path": "path",
    "components": [
      {
        "mask": false,
        "tableView": true,
        "alwaysEnabled": false,
        "label": "",
        "rows": [
          [
            {
              "components": [
                {
                  "key": "key1",
                  "valueProperty": "value",
                  "selectedKey": "ValueKey"
                }
              ]
            }
          ],
          [
            {
              "components": [
                {
                  "components": [
                    {
                      "key": "key2",
                      "valueProperty": "value",
                      "selectedKey": "ValueKey"
                    }
                  ],
                  "allowMultipleMasks": false,
                  "showWordCount": false,
                  "showCharCount": false,
                  "alwaysEnabled": false,
                  "type": "textfield",
                  "input": true,
                  "widget": {
                    "type": ""
                  }
                }
              ]
            }
          ],
          [
            {
              "components": [
                {
                  "labelPosition": "left-left",
                  "allowMultipleMasks": false,
                  "showWordCount": false,
                  "showCharCount": false,
                  "alwaysEnabled": false,
                  "input": true,
                  "widget": {
                    "type": ""
                  }
                }
              ]
            }
          ]
        ],
        "header": [],
        "numCols": 2
      }
    ]
  }
  </code></pre>
  
  <p>I'm trying to find the entire json object if it contains "selectedkey" property and replace with other object.</p>
  
  <p><strong>Expected Result:</strong></p>
  
  <pre><code>Json object { "key": "key1", "valueProperty": "value", "selectedKey": "ValueKey" } should be replaced with { "key": "key1", "valueProperty": "value", "selectedKey": "ValueKey" } 
  </code></pre>
  
  <p><strong>Note</strong>: Json object can appear at n number of times and json path of object can be anywhere in json array.</p>