# JSON3 string to Numeric

**URL:** <https://discourse.julialang.org/t/json3-string-to-numeric/96050>\
**Category:** General Usage\
**Tags:** question, json3\
**Created:** [March 14, 2023, 11:23am UTC](https://discourse.julialang.org/t/json3-string-to-numeric/96050 "2023-03-14T11:23:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliviermilla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliviermilla/32/47200_2.png) [@oliviermilla](https://discourse.julialang.org/u/oliviermilla)\
**Post date:** [March 14, 2023, 11:23am UTC](https://discourse.julialang.org/t/json3-string-to-numeric/96050/1 "2023-03-14T11:23:04Z")

</div>

I have this API that returns all data as string:

```julia
{
      value: "35.2"
}

```

Yet I want to map it to astruct with the proper type

```julia
struct Data
    vaue::Float16
end

```

How can I instruct JSON3 to do the conversion?

---

<div class="post-metadata">

**Author:** ![AMJ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amj/32/214096_2.png) [@AMJ](https://discourse.julialang.org/u/AMJ)\
**Post date:** [March 14, 2023, 11:53am UTC](https://discourse.julialang.org/t/json3-string-to-numeric/96050/2 "2023-03-14T11:53:50Z")

</div>

Welcome Olivier,

You can put your code between double " ``` " to make it more readable.

You can convert it yourself :

```julia
input = JSON3.read(string_api) #you can add your relative path with "." notation i.e. JSON3.read(string_api).value

struct Data
  value::Float16
end

#You can convert your input with "parse" function

output = Data(parse(Float16, input))

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [March 14, 2023, 11:55am UTC](https://discourse.julialang.org/t/json3-string-to-numeric/96050/3 "2023-03-14T11:55:16Z")

</div>

From the [example](https://quinnj.github.io/JSON3.jl/stable/#Read-a-quoted-number) in the docs:

```julia
using JSON3, StructTypes

j="""{"value": "35.2"}"""

struct Data
    value::Float16
end
StructTypes.StructType(::Type{Data}) = StructTypes.Struct()

d=JSON3.read(j, Data; parsequoted=true)

```
