Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Kris Dyson 54 posts 79 karma points
    Sep 29, 2011 @ 13:19
    Kris Dyson

    Json dump of the tree taking into account permissions and resolved media urls

    Hi there, I'm using Umbraco as a front-end for an iPad app.

    The iPad app needs to consume ideally a JSON feed (but could change to XML if it's easier) which expresses the full heirarchy of all the nodes from "home" root node down to all children. Each node output should also take into account whether the logged-in user has access to a given node. Also, ideally, any media nodes should be resolved to their full URL string.

    I'm thinking of writing a JSON macro which will traverse the entire tree, creates a new tree in memory and then uses the JavaScriptSerializer to output the JSON.

    What do you think of this approach? Maybe there is a better approach?




  • Rodion Novoselov 694 posts 859 karma points
    Sep 29, 2011 @ 13:37
    Rodion Novoselov

    Personally, I think that XML being got with an Xslt macro could be much simpler in this case. But, it's a matter of taste, of course - I myself just prefer xslt for creating sort of 'read-only' macros and razor / user control macros to create parts that include interactive elements. And I think that convert Xml to Json isn't that complicated task.

  • Gareth Evans 139 posts 330 karma points c-trib
    Oct 04, 2011 @ 22:28
    Gareth Evans

    I think I'd copy the sitemap razor example and in the @traverse method, just emit JSON

    Something like this should get you started:

    { id : @node.Id, name: @node.Name, children: [  @traverse(node) ]  }

Please Sign in or register to post replies

Write your reply to: