Skip to content

Instantly share code, notes, and snippets.

@clstokes
Last active Dec 29, 2015
Embed
What would you like to do?

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