json_fast icon indicating copy to clipboard operation
json_fast copied to clipboard

Don't know how to jsonify Complex

Open markjreed opened this issue 3 years ago • 3 comments

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.

markjreed avatar Dec 12 '22 19:12 markjreed

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.

2colours avatar May 05 '23 08:05 2colours

@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

timo avatar May 10 '23 15:05 timo

@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!

markjreed avatar May 10 '23 17:05 markjreed