#Can you decode into "generic" JSON values?

1 messages · Page 1 of 1 (latest)

crystal portal
#

For example, receiving a message event that I want to fan out to other clients

How could I represent data here as being a json.Json value, rather than dynamic.Dynamic?

My current idea is to reimplement some JSON types to be more dynamic

#

Can you decode into "generic" JSON values?

winter linden
#

you can't, the json type only exists when serialising.
you can use json_value to turn your data into a generic AST for example

crystal portal
#

Cool json_value looks neat

#

Would there be a performance hit with this?

#

oh I see, read the code

#

cool that's perfect. was basically what I'd reimplement

#

thank you 😊

winter linden
#

you can technically abuse some implementation details of the platform you're targetting to skip some steps in the process

#

note that this is not recommended though

crystal portal
#

beam in this case

west spear
#

Benchmark and profile first, if you learn that this is your bottleneck then you can optimise it