简体   繁体   English

如何查询Lotus视图并将结果格式化为json?

[英]How to query a Lotus view and have the result formatted as json?

I have a view called 'walking' which I want to query: 我有一个名为'walking'的视图,我想查询:

http://site/activity.nsf/walking?searchview&query=FIELD%20Gradient%20CONTAINS%20gradienteasy.gif

This returns the results in an HTML table. 这将返回HTML表格中的结果。 What I would like to do is have the results formatted as JSON which I will then use client-side. 我想要做的是将结果格式化为JSON,然后我将使用客户端。 Is this possible? 这可能吗?

I know you can get JSON returned from a straight view by doing this: 我知道你可以通过这样做从直观视图返回JSON:

http://site/activity.nsf/walking?readviewentries&outputformat=json

Scott Good and I have done several sessions at a variety of conferences on generating and consuming JSON from traditional Domino applications (not using XPages). Scott Good和我在各种会议上就传统Domino应用程序(不使用XPage)生成和使用JSON进行了多次会议。 The most recent was the "JMP303 JSON in client- and server-side code Master Class" we gave at Lotusphere 2011. Link to the presentation materials and slides are: here 最新的是我们在Lotusphere 2011上提供的“客户端和服务器端代码Master Class中的JMP303 JSON”。演示材料和幻灯片的链接是: 这里

/Newbs / Newbs

您必须创建一个标记为“将视图内容视为HTML”属性的视图,并设置一个生成所需JSON语法的列公式。

There is a nice post on OpenNTF with the code to create a very generic view which returns JSON for the documents that match the View's selection formula: http://openntf.org/XSnippets.nsf/snippet.xsp?id=use-transform-to-build-json-and-consume-the-output-in-an-xagent 在OpenNTF上有一篇很好的帖子,其代码用于创建一个非常通用的视图,该视图返回与View的选择公式匹配的文档的JSON: http ://openntf.org/XSnippets.nsf/snippet.xsp?id = use-transform -to-集结JSON和-消耗最输出中的-xagent

That sample uses an "XAgent" (Xpage with no UI) to set the content-type header, etc. But you could probably do the same thing using a $$ViewTemplate form, if needed. 该示例使用“XAgent”(没有UI的Xpage)来设置内容类型标题等。但如果需要,您可以使用$$ ViewTemplate表单执行相同的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM