You can ask a web script for a specific response format by adding a format argument to your URL. So in this case, you could do:http://localhost/alfresco/service/sample/folder/Company Home?format=jsonOut-of-the-box, you'll see an error message because there is no JSON template defined for that web script.Have no fear, though, because it is easy to add one.If you go to:http://localhost/alfresco/service/indexAnd find that sample web script, you can read its documentation. The page is:http://localhost/alfresco/service/index/uri/sample/folder/%7Bpath%7DThe description says the web script lives in the Data Dictionary/Web Scripts folder so that makes it easy for us to work with it. All you need to do is add a JSON template.To do that, go to Company Home/Data Dictionary/Web Scripts/org/alfresco/sample. Web scripts follow a specific naming convention. You'll see that the HTML template for the web script is called folder.get.html.ftl. You need to add a new one called folder.get.json.ftl. Here is a basic one to get you started:
<#escape x as jsonUtils.encodeJSONString(x)>
{
"title": "${folder.displayPath}/${folder.name?xml}",
"children" : [
<#list folder.children as child>
"${child.name?xml}"<#if child_has_next>,</#if>
</#list>
]
}
</#escape>
Once added, you can refresh the webscripts by going to http://localhost/alfresco/s/index and clicking "Refresh Web Scripts".Now, when you go to http://localhost/alfresco/s/sample/folder/Company Home?format=json you will see something like:
{
"title": "/Company Home",
"children" : [
"Data Dictionary",
"Guest Home",
"User Homes",
"Shared",
"Imap Attachments",
"IMAP Home",
"Sites"
]
}
I'll leave it to you to modify the template to give you exactly what you want.Jeff