# Query result in JSON format (java)

**URL:** <https://community.stardog.com/t/query-result-in-json-format-java/2036>\
**Category:** Support\
**Created:** [October 24, 2019, 11:40am UTC](https://community.stardog.com/t/query-result-in-json-format-java/2036 "2019-10-24T11:40:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fasal](https://avatars.discourse-cdn.com/v4/letter/f/b4bc9f/32.png) [@fasal](https://community.stardog.com/u/fasal)\
**Post date:** [October 24, 2019, 11:40am UTC](https://community.stardog.com/t/query-result-in-json-format-java/2036/1 "2019-10-24T11:40:25Z")

</div>

I was following below arcticle to connect java to stardog.

[https://www.stardog.com/tutorials/stardog-app-in-5-easy-steps/](https://www.stardog.com/tutorials/stardog-app-in-5-easy-steps/)

I was successfully able to run the code in the given tutorial. But the result it writes out is in tabular form.

`QueryResultWriters.write(tupleQueryResult, System.out, TextTableQueryResultWriter.FORMAT);`

what i want is result to be in json format.  
Not sure how can i do it.. ??

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [October 24, 2019, 11:50am UTC](https://community.stardog.com/t/query-result-in-json-format-java/2036/2 "2019-10-24T11:50:03Z")

</div>

Hi,

You can replace `TextTableQueryResultWriter.FORMAT` with `QueryResultFormats.JSON` and that should get you what you want.

---

<div class="post-metadata">

**Author:** ![fasal](https://avatars.discourse-cdn.com/v4/letter/f/b4bc9f/32.png) [@fasal](https://community.stardog.com/u/fasal)\
**Post date:** [October 24, 2019, 12:02pm UTC](https://community.stardog.com/t/query-result-in-json-format-java/2036/3 "2019-10-24T12:02:02Z")

</div>

> [@stephen](#):
>
> QueryResultFormats.JSON

thanks @stephen.. it worked 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [November 7, 2019, 12:12pm UTC](https://community.stardog.com/t/query-result-in-json-format-java/2036/4 "2019-11-07T12:12:30Z")

</div>

Closed on November 7, 2019, 12:12pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
