2020.2

Table Of Contents
String; the supplied location should be either a URL or a relative filepath. The file protocol
is supported as well as the http/https protocols. The complete syntax of a fully qualified
URL with the "file" protocol is: file://<host>/<path>. If the host is "localhost", it can be omitted,
resulting in file:///<path>, for example: file:///c:/somefolder/somejson.json.
Examples
This sample script retrieves JSON data from a snippet.
var localJSON = loadjson('snippets/jsonsnippet.json');
if(localJSON.post){
results.html("<h3>" + localJSON.post.title + "</h3><p>" +
localJSON.post.modified + "</p>");
}
This script retrieves a post from a WordPress site.
var wpPost = loadjson('http://192.168.101.58/2013/06/leave-the-
third-dimension-behind-and-focus-on-real-printing-
innovation/?json=1');
if(wpPost.post){
results.html("<h1>" + wpPost.post.title + "</h1>"
+ wpPost.post.content);
}
This script retrieves multiple posts from a WordPress site.
var numPosts = 3;
var wpPost = '';
var wpRecentPosts = loadjson('http://192.168.101.58/?json=get_
recent_posts&count=' + numPosts);
if(wpRecentPosts.posts){
for (var i = 0; i < numPosts ; i++) {
wpPost += "<p>" + wpRecentPosts.posts[i].title + "</p>";
}
}
results.after(wpPost)
loadtext()
Loads text from the specified text file, for example a JavaScript file (.js) or style sheet (.css).
The text file may be located inside the template or hosted on a Content Management System or
on another location outside the template.
Page 1286