NOTESSIDAN

Allt om Lotus Notes & Domino




JSON using xAgent
Step 1. Download org.json java library
Step 2. Copy/Paste the jar file into the jar folder using package explorer



Step 3. Create a new xAgent and paste the following code

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">
<xp:this.afterRenderResponse><![CDATA[#{javascript:try{

var externalContext = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = externalContext.getResponse();
response.setContentType("application/json");
response.setHeader("Cache-Control", "no-cache");
//var param = context.getUrlParameter("param");

var dataArray = new org.json.JSONArray();

for(i=0;i<5;i++){
var data = new org.json.JSONObject();
data.put( "item a" + i, "val a" + i );
data.put( "item b" + i, "val b" + i );
data.put( "item c" + i, "val c" + i );
dataArray.put(data)
}
writer.write( dataArray.toString());
writer.endDocument()


}catch(e){
print(e)
}
}]]></xp:this.afterRenderResponse>
</xp:view>


Step 4. Open the xpage and view the result


[
{
"item c0": "val c0",
"item b0": "val b0",
"item a0": "val a0"
},
{
"item c1": "val c1",
"item b1": "val b1",
"item a1": "val a1"
},
{
"item c2": "val c2",
"item b2": "val b2",
"item a2": "val a2"
},
{
"item c3": "val c3",
"item b3": "val b3",
"item a3": "val a3"
},
{
"item a4": "val a4",
"item c4": "val c4",
"item b4": "val b4"
}
]



Relevanta Poster på Notessidan:



Fler Poster om:

Fler bloggar om:

Technorati:

Delicious:
Publicerad 2014-03-12 | Kommentarer: 2 | Läsningar:

Kommentarer

Finn L. Knudsen ( 2014-03-12 19:59:51 )

Patrick Kwinten ( 2014-04-10 11:26:02 )



Sök på Notessidan
Thomas Adrian
ThomasCertifierad utvecklare och administratör inom Notes & Domino

Kontakta mig







Senaste Sökningarna på Notessidan
Sön - sharepoint (R:1)
Sön - räkna and antal and besökare (R:0)
Sön - browser (R:17)
Sön - stoppar and mail (R:1)
Sön - korrupt (R:3)
Sön - böcker (R:0)
Sön - kalendern (R:12)
Sön - feature (R:15)
Sön - print and mime (R:2)
Sön - länka (R:0)
Sön - databasen (R:94)
Sön - access (R:47)
Sön - outlook (R:15)
Sön - webanvändare (R:0)
Sön - google and maps (R:6)
Sön - juffe (R:2)
Sön - uidoc.print (R:1)
Sön - java and lotusscript (R:26)
Sön - besök (R:0)




Databasstatistik Blogg
Uppdateras var 15:e Minut

Antal Poster:562
Antal Kommentarer: 1405
Alla sidvisningar idag:
Unika Besökare idag:
Databasstorlek: 149,75Mb
Fixup: 2019-09-19 00:31:04
FT:2019-09-19 03:17:12
DB Procent använd: 99,9
Antal Agenter: 42
Antal Formulär: 65
Antal Vyer: 60
Antal Dokument: 7984
Antal Image Resources: 108
Antal Subformulär: 18
Antal Scriptbibliotek: 11
Totalt Antal Designelement: 576
Antal Attachments: 159
Antal Konflikter: 0
Server version 1: 405
Server version 2: Release 9.0.1FP9|August 14, 2017
Server Plattform: Windows/64
Ändrad: 2019-09-19 04:52:44
Server Tidszon: Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=131$ZN=W. Europe
Region:
Kommentarsspam Idag: 5
Kommentarsspam Totalt: 18824


BlogRankers.com

Top Sites at iWEBTOOL.com

Fight Spam! Click Here!

Bloggtoppen.se

Listed on BlogShares

Increase website traffic

Top Internet Blogs

Site Checker