Hello:
On Tue, Feb 18, 2020 at 7:39 AM Jerome Meyer <[email protected]> wrote:
> I've created one example.fson file :
> # cat files/example.json
> json_example: |
> {
> "example_simple": {
> "name": "simple",
> "foo": "value",
> "item": "this"
> },
> }
>
> Your JSON has an incorrect syntax. This is how should look like:
{
"json_example": {
"example_simple": {
"name": "simple",
"foo": "value",
"item": "this"
}
}
}
This way, your playbook just runs fine:
- shell: cat example.json
register: result
- set_fact:
myvar: "{{ result.stdout | from_json }}"
- debug: var=myvar
which produces this output:
TASK [shell]
************************************************************************************************************************************************************
changed: [localhost]
TASK [set_fact]
*********************************************************************************************************************************************************
ok: [localhost]
TASK [debug]
************************************************************************************************************************************************************
ok: [localhost] => {
"myvar": {
"json_example": {
"example_simple": {
"foo": "value",
"item": "this",
"name": "simple"
}
}
}
}
You can use this to parse your JSON files:
$ python -m json.tool < example.json
As Dick Visser said, it seems you're mixed some kind of YAML+JSON content
which invalidates it at all
--
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/CAA3McK9kJ3wUPSYKAn614vpwQCVjfyfAt1wQ3LZMhqo4ye4THA%40mail.gmail.com.