0

In an xpage I have several calls to collect data in json format from several notesviews via java class files.

To check or visualize the data I have a "debug mode" option to display this data in computed fields.

The data is json but I would like to have it formatted in the computed text so it is easier to read.

Does anyone know how I can format the display to it is easier to read in stead of one line of text?

e.g. from

{"locationName":"","gender":"Male","companyName":"","name":"Patrick Kwinten","docUNID":"845AB7AF45FF1260C1257E88003DACFA","notesName":"CN=Patrick Kwinten\/O=quintessens","branchName":"Quintessens Global Services","phone": ["+49 1525 161 223"],"info": ["IT Specialsit"],"sourceUNID":"","pictureURL":"http:\/\/dev1\/apps\/banking\/ServiceData.nsf\/0\/845AB7AF45FF1260C1257E88003DACFA\/$FILE\/PortalPicture.jpg","mail": ["patrickkwinten@ghotmail.com"],"reportsTo":"CN=Eva Fahlgren\/O=quintessens","job":"Managaer","departmentName":"Collaboration Services"}

to

{
  "locationName": "",
  "gender": "Male",
  "companyName": "",
  "name": "Patrick Kwinten",
  "docUNID": "845AB7AF45FF1260C1257E88003DACFA",
  "notesName": "CN=Patrick Kwinten\/O=quintessens",
  "branchName": "Quintessens Global Services",
  "phone": [
    "+49 1525 161 223"
  ],
  "info": [
    "IT Specialsit"
  ],
  "sourceUNID": "",
  "pictureURL": "http:\/\/dev1\/apps\/banking\/ServiceData.nsf\/0\/845AB7AF45FF1260C1257E88003DACFA\/$FILE\/PortalPicture.jpg",
  "mail": [
    "patrickkwinten@ghotmail.com"
  ],
  "reportsTo": "CN=Eva Fahlgren\/O=quintessens",
  "job": "Managaer",
  "departmentName": "Collaboration Services"
}
Patrick Kwinten
  • 1,988
  • 2
  • 14
  • 26
  • 2
    possible duplicate of [How can I pretty-print JSON using JavaScript?](http://stackoverflow.com/questions/4810841/how-can-i-pretty-print-json-using-javascript) – Armand Jul 27 '15 at 08:37
  • My coworker has a SSJS function to do this. I will bring this up to him in about an hour when I get to work. – Steve Zavocki Jul 27 '15 at 11:04
  • It looks like that other question has your answer, but if it doesn't work then let me know by commenting and I will ask him. On the surface, the stringify would seem easier. – Steve Zavocki Jul 27 '15 at 11:12
  • http://dontpanic82.blogspot.de/2010/09/xpages-ssjs-code-snippet-that-lets-you.html I do not want to parse the json I just want to display the json in formatted form via a computed text control – Patrick Kwinten Jul 28 '15 at 12:17

1 Answers1

0

I do it in a different way. I use Google Postman to fire the request (with headers or whatever you need) and then I get the result back in Postman and can view it as "pretty" - this way I don't have to build anything like this into the application - and I also prefer to see the "raw" data and not risk changing anything on manipulating it prior to displaying it the way you suggest :-)

Really can't live without this utility once I discovered it.

/John

John Dalsgaard
  • 2,797
  • 1
  • 14
  • 26