Re: [nodejs] how to display object in unnamed array in dust

20 views
Skip to first unread message

Ryan Schmidt

unread,
Jun 6, 2015, 8:25:35 AM6/6/15
to nod...@googlegroups.com
On Jun 5, 2015, at 9:40 PM, JBD wrote:

> I have JSON object called Lodge, the start of which is like this:
>
> [ { LodgeId: 12,
> HasInventory: true,
> Rooms:
> [ { Room: { Name: { invariant: 'Queen Test' }, Id: 100, Culture: null },
> LodgeId: 12,
> NightlyRates: null,
> NightlyRateErrors: null,
>
> .... etc
>
> As you can see, it's an array with no name. How do I display for example the LodgeId?
>
> I tried this but it doesn't work, displays nothing: {#Lodge}{#.}{LodgeId}{/.}{/Lodge}
>
> What am I doing wrong? Thanks.

I don't know dust syntax, but what you have there is an array, not an object. To refer to the LodgeId of the object in the first array element, in JavaScript, you would write:

Lodge[0].LodgeId

Satheesh Natesan

unread,
Jun 7, 2015, 9:34:08 AM6/7/15
to nod...@googlegroups.com
{#Lodge}{#Rooms}{LodgeId}{/Rooms}{/Lodge} will work. It will display LodgeId of all rooms.

You can try it  in http://www.dustjs.com/ with the JSON object
Reply all
Reply to author
Forward
0 new messages