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?
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.
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?
thanks
Kris
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.
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) ] }
is working on a reply...