Ways to interpolate template variables inside JavaScript objects

You could JSON.stringify the object, then replace your search value with the actual value, then JSON.parse the result:

function magic(o, a) {
    var j = JSON.stringify(o);
    for (var k in a) {
            j = j.split('${'+k+'}').join(a[k]);
    }
    return JSON.parse(j);
}

I suggest to you a very simple but very fast and understandable template engine: simple-template.js

It consists of 22 lines of code, very simple! Considering that, you will be able to render your config easily!