Closed fujie-xiyou closed 11 months ago
There is currently a known issue where the threadUnsafeSet
type was changed to a non-pointer type in version 2.2.0. As a result, when using the json.Unmarshal
function to deserialize the threadUnsafeSet
type, an error occurs and it cannot correctly enter the UnmarshalJSON
method of threadUnsafeSet. However, directly calling the UnmarshalJSON
method can successfully deserialize it.
One more question, currently threadSafeSet
and threadUnsafeSet
structs are not exported. When a struct includes a set.Set
type, json.Unmarshal
cannot be used to deserialize the struct. Could you please let me know if it's possible to make threadSafeSet
and threadUnsafeSet
exportable so that they can be used in this scenario?
Deserialize using generics. The previous deserialization method had issues in generic scenarios.
Can you be more specific what the issue was? I personally don't use the Marshal/Unmarshal too much but to my knowledge the tests were all previously passing.
One more question, currently
threadSafeSet
andthreadUnsafeSet
structs are not exported. When a struct includes aset.Set
type,json.Unmarshal
cannot be used to deserialize the struct. Could you please let me know if it's possible to makethreadSafeSet
andthreadUnsafeSet
exportable so that they can be used in this scenario?
I'd rather ideally rather not export them because the Set
interface is the type user's should be working with. Please provide a code example of what doesn't work.
There is currently a known issue where the
threadUnsafeSet
type was changed to a non-pointer type in version 2.2.0. As a result, when using thejson.Unmarshal
function to deserialize thethreadUnsafeSet
type, an error occurs and it cannot correctly enter theUnmarshalJSON
method of threadUnsafeSet. However, directly calling theUnmarshalJSON
method can successfully deserialize it.
Is this what your PR fixes? Or is this a separate issue. I would be more inclined to expedite this work if we can get a issue/PR created per issue that you are having.
Deserialize using generics. The previous deserialization method had issues in generic scenarios.
Can you be more specific what the issue was? I personally don't use the Marshal/Unmarshal too much but to my knowledge the tests were all previously passing.
The current test for Marshal/Unmarshal only includes tests for the string type. When the element type of the set is int64, you can refer to this code snippet. In reality, it cannot be deserialized successfully as expected. This pull request fixes the issue. With this correction, deserialization of int64 elements works correctly.
Deserialize using generics. The previous deserialization method had issues in generic scenarios.