# How can I handle uuid and jsob in PGSQL

**URL:** <https://discourse.julialang.org/t/how-can-i-handle-uuid-and-jsob-in-pgsql/28539>\
**Category:** Data\
**Tags:** question\
**Created:** [September 8, 2019, 12:06pm UTC](https://discourse.julialang.org/t/how-can-i-handle-uuid-and-jsob-in-pgsql/28539 "2019-09-08T12:06:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)\
**Post date:** [September 8, 2019, 12:06pm UTC](https://discourse.julialang.org/t/how-can-i-handle-uuid-and-jsob-in-pgsql/28539/1 "2019-09-08T12:06:34Z")

</div>

In my database, I’ve the below structure:

```sql
CREATE TABLE public.devices
(
    id uuid,
    data jsonb
)

```

When I run my query using this package, I got the below, how can I read the output properly?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/1/0166bd02db7190a3a3d4c1b957d315650f5f6b5a.png)

---

<div class="post-metadata">

**Author:** ![johann.spies](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johann.spies/32/8805_2.png) [@johann.spies](https://discourse.julialang.org/u/johann.spies)\
**Post date:** [September 9, 2019, 7:58am UTC](https://discourse.julialang.org/t/how-can-i-handle-uuid-and-jsob-in-pgsql/28539/2 "2019-09-09T07:58:53Z")

</div>

I am not sure how to convert the PostgreSQL-id (uuid) to a UUID-type in Julia, but using the JSON3-library you could do something like this (using my data):

```julia
julia> x = JSON3.read(df.data[1])
JSON3.Object{Base.CodeUnits{UInt8,String},Array{UInt64,1}} with 1 entry:
  :REC => {…

```

---

<div class="post-metadata">

**Author:** ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)\
**Post date:** [September 9, 2019, 5:26pm UTC](https://discourse.julialang.org/t/how-can-i-handle-uuid-and-jsob-in-pgsql/28539/3 "2019-09-09T17:26:47Z")

</div>

> [@johann.spies](#):
>
> df.data[1]

What is `df` here?

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [September 9, 2019, 5:32pm UTC](https://discourse.julialang.org/t/how-can-i-handle-uuid-and-jsob-in-pgsql/28539/4 "2019-09-09T17:32:26Z")

</div>

I think @johann.spies is assuming your data is in a DataFrame. You can get this (probably) by doing:

```julia
df = data |> DataFrame

```

to convert to a DataFrame, and then:

```julia
using JSON3; x = JSON3.read(df.data[1])

```

to read the first row’s `data` field into a `JSON3.Object` which you can work with.

---

<div class="post-metadata">

**Author:** ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)\
**Post date:** [September 9, 2019, 5:35pm UTC](https://discourse.julialang.org/t/how-can-i-handle-uuid-and-jsob-in-pgsql/28539/5 "2019-09-09T17:35:28Z")

</div>

> [@jpsamaroo](#):
>
> df = data |\> DataFrame

Thanks @jpsamaroo and @johann.spies, things are `OK` now

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/b/4b6a6838f0a1d32bb1302f3d7db753ec60eb2bae.png)
