# JSON3: ERROR: MethodError: no method matching Array{Int64,2}(::Array{Int64,1})

**URL:** <https://discourse.julialang.org/t/json3-error-methoderror-no-method-matching-array-int64-2-array-int64-1/51457>\
**Category:** General Usage\
**Tags:** json\
**Created:** [December 8, 2020, 1:28pm UTC](https://discourse.julialang.org/t/json3-error-methoderror-no-method-matching-array-int64-2-array-int64-1/51457 "2020-12-08T13:28:51Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [December 8, 2020, 4:09pm UTC](https://discourse.julialang.org/t/json3-error-methoderror-no-method-matching-array-int64-2-array-int64-1/51457/4 "2020-12-08T16:09:03Z")

</div>

I asked that some time ago, and I don’t think so.

> [@\[ANN\] JSON3.jl - Yet another JSON package for Julia](https://discourse.julialang.org/t/ann-json3-jl-yet-another-json-package-for-julia/25625/20):
>
> There currently isn’t a builtin/clean way to transform multidimensional arrays into json and back out. There’s an open issue for it, but it needs some thinking to the right API.

In your specific case, since your structure is mutable, you can directly reshape that field with `obj.par3 = reshape(obj.par3,2,3)`. My issue was worse, because my structure was immutable, and I had to define another structure just to read the json file with the same fields, but with a linear array, and then initialize the actual data structure from this temporary structure with linearized arrays.

By the way, my solution ended up not being very elegant, and someone can point to a better solution which might be useful to you as well. What I did is to define four macros, one with the fields before the matrix, two with either the matrix or the linearized form (a vector) and a third with the fields after that matrix. Something like:

```julia
macro Results_Start()
  ex = quote
    data1
    data2 
  end; esc(ex)
end
macro Results_Matrix()
  ex = quote
    atoms :: Array{Float64,2}
  end; esc(ex)
end
macro Results_Vector()
  ex = quote
    atoms :: Vector{Float64}
  end; esc(ex)
end
macro Results_End()
  ex = quote
    data4
    data5
  end; esc(ex)
end

```

Then I define two structs, with these macros, which share all the fields except the matrix or vector one:

```julia
struct Result
  @Result_Start()
  @Result_Matrix()
  @Result_End()
end

mutable struct MutableResult
  @Result_Start()
  @Result_ector()
  @Result_End()
end

```

The `MutableResult` struct is only used for reading the JSON file, reshape that matrix and initialize the immutable struct with

```julia
  return Result([getfield(R,field) for field in fieldnames(Result)]...)

```

All this seems pretty ugly, so I guess there are better solutions.

---

_[View the full topic](https://discourse.julialang.org/t/json3-error-methoderror-no-method-matching-array-int64-2-array-int64-1/51457)._
