1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-27 23:18:42 +02:00

#90 trim spaces when UnmarshalJSON

This commit is contained in:
Tao Wen
2017-07-01 00:33:42 +08:00
parent 04eae11ba5
commit fa0965a968
2 changed files with 11 additions and 13 deletions

View File

@ -618,6 +618,8 @@ func (decoder *unmarshalerDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
templateInterface.word = ptr
realInterface := (*interface{})(unsafe.Pointer(&templateInterface))
unmarshaler := (*realInterface).(json.Unmarshaler)
iter.nextToken()
iter.unreadByte() // skip spaces
bytes := iter.SkipAndReturnBytes()
err := unmarshaler.UnmarshalJSON(bytes)
if err != nil {