# How to use JSON ARRAY from mySql

**URL:** <https://forum.codewithmosh.com/t/how-to-use-json-array-from-mysql/7871>\
**Category:** Node\
**Created:** [October 11, 2021, 9:48pm UTC](https://forum.codewithmosh.com/t/how-to-use-json-array-from-mysql/7871 "2021-10-11T21:48:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GM\_sql](https://avatars.discourse-cdn.com/v4/letter/g/b4bc9f/32.png) [@GM\_sql](https://forum.codewithmosh.com/u/GM_sql)\
**Post date:** [October 11, 2021, 9:48pm UTC](https://forum.codewithmosh.com/t/how-to-use-json-array-from-mysql/7871/1 "2021-10-11T21:48:13Z")

</div>

Hi, I’d like to format appropriately Json array in order to iterate through the entries. I’m using Mariadb, Node/Express and Handlebars. What I’ve manege to get from the database is

`'["textA","textB","textC"]'`

But this is a string and I don’t have an idea how to access individual elements (I have an access to the entire array but not to individual items). Any suggestions are welcomed.

---

<div class="post-metadata">

**Author:** ![some\_random\_coder](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@some\_random\_coder](https://forum.codewithmosh.com/u/some_random_coder)\
**Post date:** [October 16, 2021, 2:51pm UTC](https://forum.codewithmosh.com/t/how-to-use-json-array-from-mysql/7871/2 "2021-10-16T14:51:21Z")

</div>

You may already found the answer, but have you tried `JSON.parse(<text_in_json>)` ?  
You can even run this in a browser console.

---

<div class="post-metadata">

**Author:** ![GM\_sql](https://avatars.discourse-cdn.com/v4/letter/g/b4bc9f/32.png) [@GM\_sql](https://forum.codewithmosh.com/u/GM_sql)\
**Post date:** [October 16, 2021, 4:36pm UTC](https://forum.codewithmosh.com/t/how-to-use-json-array-from-mysql/7871/3 "2021-10-16T16:36:47Z")

</div>

That’s the solution. But things become slightly more complicated when one works with a nested object/array.

---

<div class="post-metadata">

**Author:** ![some\_random\_coder](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@some\_random\_coder](https://forum.codewithmosh.com/u/some_random_coder)\
**Post date:** [October 16, 2021, 5:49pm UTC](https://forum.codewithmosh.com/t/how-to-use-json-array-from-mysql/7871/4 "2021-10-16T17:49:58Z")

</div>

If you are frequently dealing with JSON, then why not use Mongo? It’s somewhat odd that you have a need for dealing with complex JSON and your primary db is MariaDB. If you have trouble mapping data to your tables, you can use ORMs too.

---

<div class="post-metadata">

**Author:** ![GM\_sql](https://avatars.discourse-cdn.com/v4/letter/g/b4bc9f/32.png) [@GM\_sql](https://forum.codewithmosh.com/u/GM_sql)\
**Post date:** [October 16, 2021, 7:01pm UTC](https://forum.codewithmosh.com/t/how-to-use-json-array-from-mysql/7871/5 "2021-10-16T19:01:57Z")

</div>

Having no prior experience with rel.databases I’ve installed Xampp that comes with Maria, that seems is more preferable RDBMS by the web hosting providers.
