- 
                Notifications
    You must be signed in to change notification settings 
- Fork 689
How to recursive find and replace in multidimensional JavaScript object
        Andrey Gershun edited this page May 25, 2015 
        ·
        1 revision
      
    Source: StackOverflow
I need to find and replace values in my object when they match a regular expression (e.g. myVar); The object that I need to loop through is user defined and structure varies.
Here is an example object, shortened for simplicity.
var testObject = {
    name: "/pricing-setups/{folderId}", 
    method: "POST", 
    endpoint: "/pricing-setups/:folderId", 
    functionName: "create",
    Consumes: null,
    filename: "apicontracts/pricingsetups/PricingSetupServiceProxy.java",
    pathParam: [
        {$$hashKey: "06S",
          key: "folderId",
          value: "**myVar**"}
    ],
    queryParam: [],
    request_payload: "{'title':'EnterAname'}",
    returnList: []
}This object is passed into a master function that builds a AngularJs resource object using the passed in object.
You can use AlaSQL SEARCH operator.
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo