# \[answered\] How to convert JSONObject to string without files?

**URL:** <https://discourse.processing.org/t/answered-how-to-convert-jsonobject-to-string-without-files/3286>\
**Category:** Libraries\
**Created:** [September 5, 2018, 3:36pm UTC](https://discourse.processing.org/t/answered-how-to-convert-jsonobject-to-string-without-files/3286 "2018-09-05T15:36:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [September 5, 2018, 3:36pm UTC](https://discourse.processing.org/t/answered-how-to-convert-jsonobject-to-string-without-files/3286/1 "2018-09-05T15:36:04Z")

</div>

I have a JSON object. I want to convert it to a single string. Right now, the only method for doing this in my mind is using the saveJSONObject(…) function which saves it as a text file, and then reading that file.

However, I want to do it in without using the hard drive, as I happen to have a lot of JSON objects, and saving then reading each one of those would probably tax the hard drive, and my time waiting for it to finish doing so.

There is probably some simple function I’m not aware of that would do this process in a simple way.  
And I could probably just write a function that does that myself, however turning all of those special symbols into \n \t \u043c and other tags is something that daunts me a little bit, so I want to rely on someone else’s solution that would probably handle all of those tags better than I could.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [September 5, 2018, 3:50pm UTC](https://discourse.processing.org/t/answered-how-to-convert-jsonobject-to-string-without-files/3286/2 "2018-09-05T15:50:07Z")

</div>

If the JSON object is called `json` then you can get the string representation with  
`String s = json.toString();`

---

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [September 5, 2018, 4:09pm UTC](https://discourse.processing.org/t/answered-how-to-convert-jsonobject-to-string-without-files/3286/3 "2018-09-05T16:09:28Z")

</div>

This works well. As I said, there’s probably a simple function I’m not aware of.

Thanks a lot!
