JSON object is all nested in an array

Hi,

I’m working with mustache to convert a JSON to html.

The sample code all works fine but now i’m implementing the actual JSON from the 3rd party its not working as its all being returned in one


var data =[B] [ [/B]{ depts: [
    {   name: "Engineering",
        employees: [
            {firstName: "Christophe", lastName: "Coenraets"},
            {firstName: "John", lastName: "Smith"}]
    },
    {   name: "Sales",
        employees: [
            {firstName: "Paula", lastName: "Taylor"},
            {firstName: "Lisa", lastName: "Jones"}]
    }]
}[B]][/B];

it’s just the two brackets in bold above that stops it from working, can’t edit the response from the 3rd party. Is there something simple I can do in the mustache template to fix this?

ok fixed it, was very simple.

Just needed an array value in the mustache call as below

var html = Mustache.to_html(tpl, jsonData[0]);