HI
from programming view, you should decode json string to a data structure
(hash), then access to the hash.
my test:
$ cat a.json
{"a":123,"b":456,"c":789}
$ perl -MJSON -le 'open
FD,"a.json";$str=<FD>;$hash=JSON->new->decode($str);print $hash->{c}'
789
Thanks.
On Wed, Sep 9, 2020 at 2:59 PM [email protected] <[email protected]>
wrote:
> Morning all,
>
> have had this question from a co-worker & not managed to work out how do
> do it. Any help is greatly appreciated as I can see this coming up several
> times in the future as well.
>
> We have the following response body
>
> {
>
> "products": [
>
> {
>
> "chartName": "action-orchestrator",
>
> "installTime": 1599482114,
>
> "modifiedTime": 1599482114,
>
> "name": "Action Orchestrator",
>
> "revision": 1,
>
> "status": {
>
> "message": "Product is ready",
>
> "progressPercentage": 100,
>
> "state": "running"
>
> },
>
> "version": [
>
> "5.2.0"
>
> ]
>
> },
>
> {
>
> "chartName": "cloudcenter-shared",
>
> "installTime": 1599483017,
>
> "modifiedTime": 1599483017,
>
> "name": "cloudcenter-shared",
>
> "revision": 1,
>
> "status": {
>
> "message": "Product is ready",
>
> "progressPercentage": 100,
>
> "state": "running"
>
> },
>
> "version": [
>
> "5.4.0"
>
> ]
>
> },
>
> {
>
> "chartName": "common-framework",
>
> "installTime": 1599469174,
>
> "modifiedTime": 1599469174,
>
> "name": "Suite Admin",
>
> "revision": 1,
>
> "status": {
>
> "message": "Product is ready",
>
> "progressPercentage": 100,
>
> "state": "running"
>
> },
>
> "version": [
>
> "5.2.0"
>
> ]
>
> },
>
> {
>
> "chartName": "workload-manager",
>
> "installTime": 1599483064,
>
> "modifiedTime": 1599483064,
>
> "name": "Workload Manager",
>
> "revision": 1,
>
> "status": {
>
> "message": "Waiting for product to be ready",
>
> "progressPercentage": 67,
>
> "state": "creating"
>
> },
>
> "version": [
>
> "5.4.0"
>
> ]
>
> }
>
> ],
>
> "status": {
>
> "message": "Product install success",
>
> "progressPercentage": 100,
>
> "state": "running"
>
> }
>
> }
>
>
>
> What we need to do is search through 'products', & check that the
> 'status.state' is 'running' for a specific 'name', in our case 'Workload
> Manager'
>
> I can't work out how to provide the search, with the expected result for
> the co-wokrer to use with an 'until' module.
>
> The idea is to only execute the next task, when the 'status.state' changes
> to 'running'.
>
>
> Hope this makes sense!
>
>
> Regards
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/14ccb917-6782-48c5-9d9d-89dafb336d47n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/14ccb917-6782-48c5-9d9d-89dafb336d47n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAMn7GYnmTVp%2BqFBRnt1okE%2BNPU2eZTJiwe7-9uX_RSW-CQhqpw%40mail.gmail.com.