JSON output from TWiki/(Foswiki)

Lately I've been using some time with TWiki. I noticed there were no easy to find instructions on how to create search results in javascript JSON-format. Here's how (works probably in Foswiki as well):

{ "arRay": [ %SEARCH{... separator="," format="[' item1,'item2','item3']"}% ] } 

This creates a JSON-compatible array. Notice the separator which makes sure that there's no trailing comma in the end of the result list. Otherwise the file would not work in IE without removing comma. To get only JSON and no unnecessary HTML elements from skin, use url parameter:


It's possible to store topic specific skin preference by adding following in the beginning of the topic (after saving preference disappears from editable topic body) (source):

%META:PREFERENCE{name="SKIN" title="SKIN" type="Set" value="text"}%

Update: More actions > topic settings can be used to customize topic preferences easier. Another alternative to access settings: use url-parameter: ?action=editSettings

No comments: