Conversation
currently only supporting string as the key type
|
Linking back to upstream rluba#35 @Stuart-Mouse I think I roughly understand the gist of the trick you are pulling off here. It's pretty cool actually! I have only one question though. If the implementation of the original Also,
I don't think any other key type needs any support. Afaik, JSON objects only support string keys anyway. :D |
|
@rexim Unfortunately yeah, I think certain changes to the hash table would cause the Any_Hash_Table to break. I'm not sure how avoidable that is though, since there's no way around the fact that in order to do this in a runtime-generic way you have to entirely reimplement the basic procedures. I could add some more asserts to help prevent basic things like if the struct parameters get reordered or if the internal layout changes at all, but if the actual logic changes for how hashing occurs, then things could just silently break. (From the maintainer's side this is probably not too much of an issue since any changes to Hash Table should be reflected in the changelog for the language, but of course its not ideal if users of Jaison just get an inexplicable break one day because they didn't pull the latest version.) This is sort of the reason I think it may be better to offer a generalized intercept so that users can poke in their own special handling for things like the Hash_Table. I think if users are knowingly taking the extra dependency then at least they'll be aware that it's a potential point of failure. I have some similar functionality in my own parser that I could try replicating here. If you think that's a better idea I can throw together a little proposal in a different PR and we put a pin in the Hash Table thing until then. |
Yeah, I feel like subtle undetected changes may send the users down a very annoying rabbit hole... My idea was to make Jaison operate on |
|
Hey guys! A simpler solution might be to change And then one could use the non-polymorphic version in For that we would have to modify What do you think? |
|
Actually, I have just looked at the implementation of |
This is a good analysis. I (a heavy user of Jaison in prod) definitely don't want a core infra piece to be very fragile like this. I like the interceptor idea. Unless we get better language support to do this, this approach is both simple and widely used in other languages. It's also what we did for jai-postgres (another great core infra piece by Raphael!) for handling custom types like the ones coming from Postgres extensions. |
Currently only supporting string as the key type.