# Help with JSON2.jl

**URL:** https://discourse.julialang.org/t/help-with-json2-jl/31433
**Category:** General Usage
**Created:** [November 23, 2019, 8:39pm UTC](https://discourse.julialang.org/t/help-with-json2-jl/31433 "2019-11-23T20:39:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cwiese](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cwiese/32/4295_2.png) [@cwiese](https://discourse.julialang.org/u/cwiese)
#### Post date: [November 23, 2019, 8:39pm UTC](https://discourse.julialang.org/t/help-with-json2-jl/31433/1 "2019-11-23T20:39:50Z")

</div>

What am I doing wrong here? I get **ERROR:** MethodError: no method matching nQ

```julia
julia> mutable struct Q
           name::String
           scens::Vector{String}                               
           nQ(name, scens) = new(name,scens) 
       end

julia> q1 = """{
                   "name": "q1",
                   "scens": ["M00000001"]
               }"""

julia> JSON2.read(q1, Q)
ERROR: MethodError: no method matching Q(::String, ::Array{String,1})

```

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [November 23, 2019, 9:15pm UTC](https://discourse.julialang.org/t/help-with-json2-jl/31433/2 "2019-11-23T21:15:32Z")

</div>

> [@cwiese](#):
>
> nQ(name, scens) = new(name,scens)

remove this line or change `nQ` into `Q`

---

<div class="post-metadata">

### Author: ![cwiese](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cwiese/32/4295_2.png) [@cwiese](https://discourse.julialang.org/u/cwiese)
#### Post date: [November 23, 2019, 9:46pm UTC](https://discourse.julialang.org/t/help-with-json2-jl/31433/3 "2019-11-23T21:46:56Z")

</div>

thanks, that was a typo from reducing my issue… I will add the rest of the properties

---

<div class="post-metadata">

### Author: ![cwiese](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cwiese/32/4295_2.png) [@cwiese](https://discourse.julialang.org/u/cwiese)
#### Post date: [November 24, 2019, 12:59am UTC](https://discourse.julialang.org/t/help-with-json2-jl/31433/4 "2019-11-24T00:59:39Z")

</div>

Okay here is the full version (and thanks for looking)

```julia
using JSON2

struct ClientSortBy
    colName::String
    revDir::Int32 # 0 asc 1 desc
    ClientSortBy(colName::String, revDir::Int32) = new(colName,revDir)
    ClientSortBy(d::Dict{String, Any}) = new(d["colName"], d["revDir"])
end

struct ClientFilter
    colName::String
    colAttr::String
    ClientFilter(colName::String, colAttr::String) = new(colName,colAttr)
    ClientFilter(d::Dict{String, Any}) = new(d["colName"], d["colAttr"])
end

mutable struct ClientnQ
    name::String
    scens::Vector{String}
    joinScens::Vector{String}
    filters::Vector{Vector{ClientFilter}}
    groupBy::Vector{Vector{String}}
    msrs::Vector{String}
    joinMsrs::Vector{String}
    sortBy::Vector{ClientSortBy}
    ClientnQ(name,scens,joinScens,filters,groupBy,msrs,joinMsrs,sortBy) =
        new(name,scens,joinScens,map(f->map(i->ClientFilter(i["colName"],i["colAttr"]),f),filters),groupBy,msrs,joinMsrs,map(s->ClientSortBy(s["colName"],s["revDir"]),sortBy))
end

q1 = """{
            "name": "q1",
            "scens": ["M00000001"],
            "joinScens": [],
            "filters": [[{"colName": "ENC_TYPE", "colAttr": "Inpatient"}]],
            "groupBy":[["PAT_CLASS"],[]],
            "msrs":["NET_REVENUE"],
            "joinMsrs":[],
            "sortBy":[{ "colName": "PAT_CLASS", "revDir":0}]
        }"""

JSON2.read(q1,ClientnQ)

```

I get " **ERROR:** MethodError: no method matching getindex(::ClientFilter, ::String)"

---

<div class="post-metadata">

### Author: ![cwiese](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cwiese/32/4295_2.png) [@cwiese](https://discourse.julialang.org/u/cwiese)
#### Post date: [November 24, 2019, 1:57pm UTC](https://discourse.julialang.org/t/help-with-json2-jl/31433/5 "2019-11-24T13:57:33Z")

</div>

never mind … the whole point of JSON2 was that is attempt to constructs the type … so this was not needed : map(f-\>map(i-\>ClientFilter(i[“colName”],i[“colAttr”]),f),filters)
