avram icon indicating copy to clipboard operation
avram copied to clipboard

JSON serialize with Array does not work

Open confact opened this issue 3 years ago • 0 comments

When having an array of a type in the JSON::Serializable, it doesn't work to use:

column exceptions : Array(Sentry::Exception), serialize: true

The one above doesn't work at all as

Error: no overload matches 'JSON::Lexer.new' with type Array(String)

With trace to:

Error: instantiating 'JSON::Serializable::Lucky(Sentry::Exception).class#parse(Array(String))'

When mentioning this error on discord, I tested:

column exceptions : Sentry::Exception, serialize: true

Which don't complain, and make sense as JSON::Serializable makes some handle under the hood with Array. But now I can't save, as the type return in the type is Array(Sentry::Exception) and not Sentry::Exception And get type wrong error from Avram when trying to save. (wrong params)

So I now have to use JSON::Any temporarily till this is fixed.

Having the full support of JSON Serialize would simplify JSON handling in the database and the saving of the same.

confact avatar May 27 '22 23:05 confact