timo / json_fast

a naive imperative json parser in perl6, to evaluate performance against JSON::Tiny
Artistic License 2.0
27 stars 20 forks source link

Don't know how to jsonify Complex #84

Open markjreed opened 1 year ago

markjreed commented 1 year ago

So it seems like Complex should be in the list, but is there any way around this without modifying the code to JSON::Fast itself? The type handling appears to be all hard-coded. Seems like falling back to whatever the stringification is would make sense.

2colours commented 1 year ago

Pretty sure JSON does not know complex numbers so there is no point in "jsonifying" them.

This module is not a serializer that uses JSON format under the hood - its very purpose is to convert from and to JSON-eligible data.

timo commented 1 year ago

@markjreed please check out the branch https://github.com/timo/json_fast/tree/converter_func and see if the proposed API can help with your issue

markjreed commented 1 year ago

@2colours Well, I wasn't looking for a way to round-trip arbitrary types through JSON and have them come through unscathed, at least not without writing some extra code. Just looking for a way to hook in that extra code without rewriting the module.

@timo the converter_func branch works a treat, thanks!