简体   繁体   中英

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

I have a view called 'walking' which I want to query:

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

This returns the results in an HTML table. What I would like to do is have the results formatted as JSON which I will then use client-side. Is this possible?

I know you can get JSON returned from a straight view by doing this:

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). 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

/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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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