使用JavaScript将Sharepoint在线文件结构转换为json文件 [英] Get Sharepoint online file structure into json file using javascript

查看:132
本文介绍了使用JavaScript将Sharepoint在线文件结构转换为json文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,我是用户体验设计师,并且正在设计Global Enterprise知识库.数据无处不在.我需要能够提取目录列表在线(托管在Office 365上)共享点存储库中的文件,并将其放在json文件中.然后允许用户选择文件并下载.我最需要的是能够从存储库中获取列表.我已经阅读了MSDN的大量文档,现在比以往任何时候都更加困惑.我在HTML5,CSS3和Java方面都很弱.感谢所有帮助.

I have a problem, I am a UX Designer and I am designing a Global Enterprise knowledge base. Data is stored everywhere. I need to be able to pull a list of directories & files from an online (hosted on Office 365) sharepoint repository and place it in a json file. Then allow the users to select the files and download them. My biggest need is to be able to get the list from the repository. I have been through the tons of documentation from MSDN, and now more confused than ever. I am strong in HTML5, CSS3, and kind-of weak in Javascript. All help is appreicated.

推荐答案

如果要以JSON格式检索文件夹和文件,则可以使用jQuery的AJAX和REST来检索数据.

If you want to retrieve folders and files in a JSON format, you can use jQuery's AJAX and REST to retrieve the data.

您的文件夹是文档库,仍然是SharePoint列表.

Your folders are document libraries, which are still SharePoint lists.

$.ajax({
    url:"/_api/lists/",
    headers: { "Accept": "application/json; odata=verbose"},
    success:function(data) {
        $.each(data.d.results, function(i, item) {
            //here you can iterate through your items
            data.d.results[i].FIELDNAME;
        })
    }
});

您仍将需要使用过滤器来仅选择文档库.您最好的猜测可能是根据内容类型进行过滤.

You will still need to use filters to select only your document libraries. Your best guess might be filtering by the content type.

以下是ODATA文档,用于过滤您的内容:

Here is the ODATA documentation to filter your content:

http://www.odata.org/documentation /odata-version-2-0/uri-conventions/

获得所需列表后,您可以在此处查询特定列表:

Once you get the list you want, here you can query a specific list:

$.ajax({
    url:"/_api/lists/getbytitle('LISTNAME')/items",
    headers: { "Accept": "application/json; odata=verbose"},
    success:function(data) {
        $.each(data.d.results, function(i, item) {
            //here you can iterate through your items
            data.d.results[i].FIELDNAME;
        })
    }
});

这篇关于使用JavaScript将Sharepoint在线文件结构转换为json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆