# Handling JSON Query Results with Python

**URL:** <https://community.stardog.com/t/handling-json-query-results-with-python/2003>\
**Category:** Support\
**Created:** [October 11, 2019, 7:30pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003 "2019-10-11T19:30:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tschneider](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@tschneider](https://community.stardog.com/u/tschneider)\
**Post date:** [October 11, 2019, 7:30pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/1 "2019-10-11T19:30:37Z")

</div>

Is there a 'simple' way to extract SPARQL query results, returned as JSON, using Python? I'm not a Python expert and it doesn't seem JSON friendly.

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [October 11, 2019, 7:44pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/2 "2019-10-11T19:44:55Z")

</div>

Are you saying that Python doesn't seem JSON friendly? If you're building a client application, perhaps you can consider using [pystardog](https://github.com/stardog-union/pystardog).

Jess

---

<div class="post-metadata">

**Author:** ![tschneider](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@tschneider](https://community.stardog.com/u/tschneider)\
**Post date:** [October 11, 2019, 7:58pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/3 "2019-10-11T19:58:57Z")

</div>

Jess,

Yes, I’m building a client application: Executing SPARQL queries and extract the bits.

The application needs to avoid non-generic libraries. And I did look at pystardog, but I didn’t see anything in the documentation that suggested it provided a  
‘simple’ way to extract ‘bits’ from a JSON result. Did I miss it?

Thank you.

Todd

![image001.jpg](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/f003192a1f3cbff81737c51a6c1ed5f5dd97394e.jpeg)

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [October 11, 2019, 8:00pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/4 "2019-10-11T20:00:08Z")

</div>

What is the significance of JSON here? It's just one way to represent a SPARQL query result.

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [October 11, 2019, 8:01pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/5 "2019-10-11T20:01:25Z")

</div>

You could always return your results as csv if that's easier for you.

---

<div class="post-metadata">

**Author:** ![tschneider](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@tschneider](https://community.stardog.com/u/tschneider)\
**Post date:** [October 11, 2019, 8:15pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/6 "2019-10-11T20:15:56Z")

</div>

Jess,

There’s no significance of JSON, just going from previous experience using JAVA with SPARQL queries via HTTP calls

Todd.

![image001.jpg](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/f003192a1f3cbff81737c51a6c1ed5f5dd97394e.jpeg)

---

<div class="post-metadata">

**Author:** ![tschneider](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@tschneider](https://community.stardog.com/u/tschneider)\
**Post date:** [October 11, 2019, 8:17pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/7 "2019-10-11T20:17:25Z")

</div>

Zachary,

I didn’t see CSV as an option for ‘Accept’ (in an HTTP GET call) in the Stardog documentation.

Todd

![image001.jpg](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/f003192a1f3cbff81737c51a6c1ed5f5dd97394e.jpeg)

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [October 11, 2019, 8:26pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/8 "2019-10-11T20:26:35Z")

</div>

text/csv should be in there [https://stardog.docs.apiary.io/reference/core-api/executing-a-query](https://stardog.docs.apiary.io/reference/core-api/executing-a-query)

---

<div class="post-metadata">

**Author:** ![tschneider](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@tschneider](https://community.stardog.com/u/tschneider)\
**Post date:** [October 11, 2019, 8:59pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/9 "2019-10-11T20:59:02Z")

</div>

Zachary,

I didn’t see the ‘extended’ list of ‘Accept’ types in  
[**https://stardog.docs.apiary.io/reference/core-api/executing-a-query**](https://stardog.docs.apiary.io/reference/core-api/executing-a-query) when I looked earlier.

The ‘text/csv’ should do the job nicely.

Thank you.

Todd

![image001.jpg](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/f003192a1f3cbff81737c51a6c1ed5f5dd97394e.jpeg)

---

<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:** [October 25, 2019, 8:59pm UTC](https://community.stardog.com/t/handling-json-query-results-with-python/2003/10 "2019-10-25T20:59:04Z")

</div>

Closed on October 25, 2019, 8:59pm UTC

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