# table save to json?

**URL:** <https://forum.kx.com/t/table-save-to-json/8959>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [July 15, 2014, 9:09am UTC](https://forum.kx.com/t/table-save-to-json/8959 "2014-07-15T09:09:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ag12](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@ag12](https://forum.kx.com/u/ag12)\
**Post date:** [July 15, 2014, 9:09am UTC](https://forum.kx.com/t/table-save-to-json/8959/1 "2014-07-15T09:09:00Z")

</div>

I tried utilizing json.k in a hackathon this weekend and it was easy to use. Saving a table as a json file was more difficult.

can ‘save’ output json? [http://code.kx.com/wiki/Reference/save](http://code.kx.com/wiki/Reference/save)

I tried modding q.k but did not succeed… save calls .h.tx calls .h.jd

jd:{.j.j 0:x} /.j.j from [http://kx](http://kx).com/q/e/json.k

tx:`csv`txt`xml`xls`json!(cd;td;xd;ed;jd);

q)x:(letter:`a`b;number:1,2)

  

q)save `x.json

k){$[1=#p:`\:*|`\:x:-1!x;set[x;. \*p]; x 0:.h.tx[p 1]@.\*p]}

'type

0:

`:x.json

+`letter`number!(`a`b;1 2)

q.q))

---

<div class="post-metadata">

**Author:** ![Attila](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Attila](https://forum.kx.com/u/Attila)\
**Post date:** [July 15, 2014, 9:38am UTC](https://forum.kx.com/t/table-save-to-json/8959/2 "2014-07-15T09:38:00Z")

</div>

jd:.j.j

should work  
Attila
