All json keys are strings, so the default key-fn stringifies all key values. In general, most uses of the json write functions will be passing a map with either all keyword or all string keys - in those cases, it's not possible for any duplicate key to occur.
While it would be possible to transform the keys and/or track written keys, either of these approaches are expensive to perform given that they are usually not needed. Thus, you should ensure the stringified keys of your objects are unique prior to calling write, if there is some chance of duplication.