Re: [xwiki-users] Parsing external JSON with Velocity in XWiki

2016-04-20 Thread Mahomed Hussein
Thanks for the quick response. I had looked at the VelocityTools page several 
times before posting. Unfortunately it wasn't very useful to me as a beginner 
as there weren't any examples of how to use it (and I couldn't deduce the 
syntax and requirements from looking at the source of the tools).

Anyway, this page may have a groovy example that might work for me. I just 
haven't had the time to test it today (and it seems the need to read the JSON 
may now been cancelled anyway) - 
http://extensions.xwiki.org/xwiki/bin/view/Extension/GitHub+Integration

Thanks again for the help.


Kind regards,




Mahomed Hussein
Custodian Data Centre
Email: maho...@custodiandc.com
http://www.CustodianDC.com

-Original Message-
From: users [mailto:users-boun...@xwiki.org] On Behalf Of Vincent Massol
Sent: 19 April 2016 18:38
To: XWiki Users <users@xwiki.org>
Subject: Re: [xwiki-users] Parsing external JSON with Velocity in XWiki


> 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
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Parsing external JSON with Velocity in XWiki

2016-04-19 Thread Vincent Massol

> On 19 Apr 2016, at 19:18, Mahomed Hussein  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


[xwiki-users] Parsing external JSON with Velocity in XWiki

2016-04-19 Thread Mahomed Hussein
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?

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
Email: maho...@custodiandc.com
http://www.CustodianDC.com
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users