I have an object like this.
var obj = {Id:1,Rate:5,Price:200,Name:\"History\"}
And a template like this.
var templateString
Just this will work for you if it has just one occurrence
var optionString = templateString.replace('{Id}',obj.Id).replace('{Name}',obj.Name)