# JSON formatting on register value.

**URL:** <https://forum.ansible.com/t/json-formatting-on-register-value/22620>\
**Category:** Ansible Project\
**Created:** [September 22, 2016, 6:26pm UTC](https://forum.ansible.com/t/json-formatting-on-register-value/22620 "2016-09-22T18:26:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [September 22, 2016, 6:26pm UTC](https://forum.ansible.com/t/json-formatting-on-register-value/22620/1 "2016-09-22T18:26:10Z")

</div>

I have a playbook that use the S3 module to list items:

`

- name: List s3 bucket

local\_action:  
module: s3  
bucket: “{{ S3\_BUCKET\_NAME }}”  
mode: list  
register: S3\_LIST\_ITEM

`

The result I output to a file using lineinfile:

`

name: Output to folder

local\_action:  
module: lineinfile  
create: yes  
line: “{{ S3\_LIST\_ITEM.s3\_keys }}”  
dest: “{{ S3\_BUCKET\_FILE }}”  
state: present

`

However this results in a JSON format:

[‘HelloWorld.sh’, ‘bucket1/’, ‘test1’]

I tried using jinja2 filter (from\_json),

e.g. line: “{{ S3\_LIST\_ITEM.s3\_keys }}”| from\_json

But that didn’t work as it gave me:

`  
fatal: [localhost]: FAILED! =\> {“failed”: true, “msg”: “Unexpected templating type error occurred on ({{ S3\_LIST\_ITEM.s3\_keys|from\_json }}): expected string or buffer”}

`

There is also no stdout\_lines equivalent so how can I put this in a text format that separate each value in a new line?

---

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [September 23, 2016, 3:32pm UTC](https://forum.ansible.com/t/json-formatting-on-register-value/22620/2 "2016-09-23T15:32:26Z")

</div>

FYI I figured it out that I needed to use with\_item to parse the JSON.
