json-iterator / go

A high-performance 100% compatible drop-in replacement of "encoding/json"
http://jsoniter.com/migrate-from-go-std.html
MIT License
13.34k stars 1.02k forks source link

Wrap panics on derived types #609

Open rickb777 opened 2 years ago

rickb777 commented 2 years ago

Referring to https://go.dev/play/p/V-1m3E14NO2

The result of running this is

The reason is because ID is a derived type, but the Wrap function performs a hard type assertion to the predefined type string. The same problem would arise for most of the cases in the switch statement in Wrap.

This means that derived types cannot be used, which is a significant limitation.