This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Sep 6, 2014, 12:36 AM
37 Posts

json output

  • Category: Other
  • Platform: All
  • Release: 9.0.1
  • Role: Administrator,Developer
  • Tags: json,rest,jquery
  • Replies: 9

I am trying to go about a json output and am looking for some direction.

The json will only need a couple of fields and I know that I can generate this a couple of different ways now, java, js, extlib, domino api but what I am getting jammed up on is the details. If you take a look at the below json snippet you will see two items, with the second item having multiple data ranges. In terms of a Notes view how would I get the data out. 

This is to implement a Gantt/resource chart in xpages. Each person would be entering a form with a start end end date. The so if someone has two entries (name2) they would have each of their dates in multiple values but only one name listed.

{
name: "Name1",
desc: "Deployment",
values: [{
from: "/Date(1336611200000)/",
to: "/Date(1338711200000)/",
label: "Deployment", 
customClass: "ganttOrange"
}]
},{
name: "Name2",
desc: "Deployment2",
values: [{
from: "/Date(1336611200000)/",
to: "/Date(1338711200000)/",
label: "Deployment", 
customClass: "ganttOrange"
},
{
from: "/Date(1338933200000)/",
to: "/Date(1338933200000)/",
label: "Deployment", 
customClass: "ganttOrange"
}]
}
Sep 7, 2014, 10:04 PM
37 Posts
Native Notes View

Yes, that may work for native json output but I am not sure how it would work to generate this specific json.

The first two fields (names&desc) are easy. But when you get to values it becomes a little more difficult. I do not think the notes view will work. Unless there is some way to work with categorized views to manipulate the json output. Take a look at my json example. Name2 would be two different forms completed by the same individual. Below is an idea on how it would look in a Notes view. Do you know of a way to manipulate the view output to get what I am looking for?

I am thinking I would need to generate the json via a script. First get all the values of Names which would be the first categorized column, then loop through each view entry to create the values.

 

Name1 | Desc

                       From | To | Label | Custom Class

Name2 | Desc

                       From | To | Label | Custom Class

                       From | To | Label | Custom Class

 
Sep 7, 2014, 10:40 PM
586 Posts
hmmm

I've not really gotten to into JSON just yet but I really want to.  

I did use some JSON inside my old crappy project - XPages Media Player.  It's not a great app by any stretch and I want to redo it but inside there I did some cusom JSON inside SSJS to feed the Prokjekktor video player.

If you're able to use Java the next NotesIn9 video - 152 will touch on JSON from Java.  I'm not sure how indepth it is but it might give you some ideas.  That video should be out in the next couple of hours.  

 

Good Luck

 

Sep 8, 2014, 12:44 AM
37 Posts
Java json

David, Thanks for the heads up. I will take a look at the next video. Good timing.

Not sure if you have seen any example of this kind of data exposed via json. Its kind of similar to a repeat inside of a repeat. Looking at xpagescheetsheet (which is a big help thanks david) take your state example. That is very similar to what I was trying to do here. Where the outer repeat collects all the states and the inner repeat shows the data from different documents. 

This is the project I am trying to implement by the way. http://taitems.github.io/jQuery.Gantt/ Getting it to run in xPages was easy. Feeding it Domino data is proving to be more of a challenge. 

I am really excited by this as it gives a better group availability calendar /resource chart than what is available in either standard notes client or even the Keith Stric's jQueryFullCalendar implementation(which i use a ton). http://www.keithstric.com/A55BAC/keithstric.nsf/default.xsp?documentId=C4ACC1CA300C873786257B15007F7732

 

Sep 8, 2014, 12:57 AM
586 Posts
stuff

Well for the Projekktor stuff I had to make JSON with a nested object inside...  I was able to pull that off with SSJS and the toJSon() stuff I believe...  That was similar to the values part of your json I think.  If you can't find it in the media library template I can try and dig out the code tomorrow..  it's really simple though...  would have to be if I did it. haha

 

XPages Java has built in some good code for json as seen in today's video I believe... but I THINK the gold standard is GSON and that's not all the difficult to add to your project.  Actually I think that's included with OpenNTF essentials.

 

I'm glad you like the cheatsheet...  I'm hoping to rebuild the demos soon with bootstrap and domino 9.0.1 and ext. library.

Sep 9, 2014, 12:22 AM
37 Posts
media template

David, was the code you were talking about in cc_XPagesVideoPlayer?

 

Sep 9, 2014, 12:55 AM
586 Posts
JSON

Yes...  I believe so..  

I pasted the code I used below in a paste bin and straight.  Not sure which is easier.  This code is direct from my XPages.TV site.

I actually have no idea how helpful this is for you...  but I was able to make some json from SSJS using the toJson() function.  The json did some of that "nested" stuff that I thought you were asking about.

Hopefully this helps at least a little.  :)

 

Dave

 

 

http://pastebin.com/nSRCtgnJ

 

<xe:restService id="restService3" pathInfo="json">

<xe:this.service>

<xe:customRestService>

<xe:this.doGet><![CDATA[#{javascript:// Since we can't use compositeData to set vars, and don't want to use the URL Parameters...

// We're going to need to use scoped Variables.

// Using viewScope so everything can be controlled set via the current page.

 

var showAd = sessionScope.get("ssShowAd" || false);

var adUrl = sessionScope.get("ssAdUrl");

var adType = sessionScope.get("ssAdType");

var mainUrl = sessionScope.get("ssMainUrl");

var mainType = sessionScope.get("ssMainType");

 

 

 

// Now start setting up the playList Array.  Projekktor wants an Array of JSON Objects.

// playList is the Master Array that gets turned into JSON and returned.

var playList = new Array();

 

 

// We need an object for the first video.  Typically an Ad

// Since this is optional then let's use an if statement.

 

if (showAd == 'true') {

// We're going to show a Pre-Roll Ad

// This object is called "PlayListVideo1".  It needs to hold the URL and type as well as config parameters 

var playListVideo1 = {};

// Now let's create the config object for the first video.

var adConfig = {};

 

// finally one more object to hold the URL and type of the first video. 

var adVideo = {};

adVideo["src"] = adUrl;

adVideo["type"] = adType;

 

// Now put the adVideo Object into the overal Playlist Object

playListVideo1[0] = adVideo;

// /////////playList.push(playListVideo1)

 

// Now create the configuration of the first video

adConfig["disablePause"] = true;

adConfig["disallowSkip"] = true;

 

// and put that config unto the first Video object

playListVideo1["config"] = adConfig;

 

// Now put this completed playListVideo1 object which contains the "adVideo" object and the "adConfig" object 

// into the array.

playList.push(playListVideo1)

 

}

 

 

// Now do the REAL video

var mainVideo = {};

mainVideo["src"] = mainUrl

mainVideo["type"] = mainType

 

// Ad the mainVideo object to a new playListVideo2 object

var playListVideo2 = {};

playListVideo2[0] = mainVideo

 

// Ad the second video to the overall Array

playList.push(playListVideo2)

 

//Convert it all into JSON

// this can be testest by looking at the URL:

//http://my.domain.com/myDatabase.nsf/myPage.xsp/json

return toJson(playList)

}]]></xe:this.doGet>

</xe:customRestService>

</xe:this.service>

</xe:restService>


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal