> On 19 Apr 2016, at 19:18, Mahomed Hussein <maho...@custodiandc.com> wrote: > > Hi > > I started off on something I thought would be simple, but my limited > knowledge is failing me and Google isn’t bringing up anything useful. > > Basically, I have a url that returns JSON content (for the sake of this > example – assume the url is https://status.com/api/status.json) > The content returned by the URL is: > > {"page":{"id":"9jyl5nk7mszv","name":"Custodian > DataCentres","url":"http://status.custdc.net","updated_at":"2016-04-19T15:45:36.626+01:00"},"status":{"indicator":"none","description":"All > Systems Operational"}} > > What I wanted to do was to simply read that JSON and then process the values > and possibly output something like: > > Status: All Systems Operational > Last Update: 2016-04-19T15:45:36 > > So far I have managed to get the URL content with: > > {{velocity}} > #set($jsoncontent = > $xwiki.getURLContent(‘https://status.com/api/status.json’)) > $jsoncontent > {{/velocity}} > > This is where I get stuck. How do I get the $jsonconent into an array or > somehow read the values?
There’s a $jsontool you can use in velocity, see http://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity+Module#HVelocityTools Otherwise you can also use groovy instead which supports reading and parsing JSON by default. Several examples are on extensions.xwiki.org. Thanks -Vincent > Apologies for the basic question, but I hope someone can either point me in > the right direction or provide an example I can work from. Thanks. > > > Kind regards, > > > Mahomed Hussein > Custodian Data Centre _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users