Skip to content

Instantly share code, notes, and snippets.

@clstokes
Last active December 29, 2015 02:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save clstokes/7602673 to your computer and use it in GitHub Desktop.

How can I combine these two JSON documents...

{
  variables: {
    frontendPort: "80",
    backendPort: "8080"
  }
}

{
  applications: [
    {
      name: "app1",
      frontendPort: "$frontendPort",
      backendPort: "$backendPort"
    },
    {
      name: "app1",
      frontendPort: "$frontendPort",
      backendPort: "$backendPort"
    }
  ]
}

to produce this one?

{
  applications: [
    {
      name: "app1",
      frontendPort: "80",
      backendPort: "8080"
    },
    {
      name: "app1",
      frontendPort: "80",
      backendPort: "8080"
    }
  ]
}

The string replacement may happen N levels deep in the object graph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment