My problem is different, my data looks like this :
var categories = [
    {"id":"Cart","name":"Ma commande"},
    {"id":18,"name":"Menus"},
    {"id":14,"name":"Entr\u00e9es"},
    {"id":5,"name":"Plats","items":[
        {"id":7,"name":"Viandes"},
                {"id":8,"name":"Poissons"},
                {"id":11,"name":"Pizzas"}]
        },
        {"id":15,"name":"Desserts"},
        {"id":17,"name":"Boissons","items":[
                {"id":1,"name":"Alcoolis\u00e9es"},
                {"id":3,"name":"Sans alcool"}]
        }
]
Entries without items should be <option>, Entries with items should be <optgroup> and the items of the entry must be <option> of <optgroup>
How can I achieve that ?