StructTypes.jl icon indicating copy to clipboard operation
StructTypes.jl copied to clipboard

`Real` does not deserialize

Open heyx3 opened this issue 2 years ago • 2 comments

Julia Version: 1.7.2.

I see that Real is supposed to be StructTypes.NumberType(), but it can't actually deserialize:

julia> JSON3.read("456", Real)
ERROR: ArgumentError: invalid JSON at byte position 1 while parsing type Real: ExpectedOpeningObjectChar
456
julia> JSON3.read("456", Union{Integer, AbstractFloat})
456.0

heyx3 avatar Jul 05 '23 14:07 heyx3

Can you share what version of JSON3/StructTypes you have? I'm not seeing the same problem:

julia> using JSON3

julia> JSON3.read("456", Real)
456.0

quinnj avatar Jul 06 '23 03:07 quinnj

StructTypes v1.8.1

JSON3 v1.9.2

Here's an exact printout of my session:

  | | |_| | | | (_| |  |  Version 1.7.2 (2022-02-06)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(Bplus) pkg> status StructTypes
     Project Bplus v0.1.0
      Status `C:\Users\manni\Documents\Code\B-plus\Project.toml`
  [856f2bd8] StructTypes v1.8.1

(Bplus) pkg> status JSON3
     Project Bplus v0.1.0
      Status `C:\Users\manni\Documents\Code\B-plus\Project.toml`
  [0f8b85d8] JSON3 v1.9.2

julia> using JSON3; JSON3.read("45", Real)
ERROR: ArgumentError: invalid JSON at byte position 1 while parsing type Real: ExpectedOpeningObjectChar
45

heyx3 avatar Jul 06 '23 03:07 heyx3