You've already forked json-iterator
							
							
				mirror of
				https://github.com/json-iterator/go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	fix #190 handle empty input
This commit is contained in:
		| @@ -4,6 +4,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"reflect" | ||||
| 	"errors" | ||||
| ) | ||||
|  | ||||
| // Any generic object representation. | ||||
| @@ -157,6 +158,8 @@ func (iter *Iterator) readAny() Any { | ||||
| 		return iter.readArrayAny() | ||||
| 	case '-': | ||||
| 		return iter.readNumberAny(false) | ||||
| 	case 0: | ||||
| 		return &invalidAny{baseAny{}, errors.New("input is empty")} | ||||
| 	default: | ||||
| 		return iter.readNumberAny(true) | ||||
| 	} | ||||
|   | ||||
| @@ -104,6 +104,11 @@ func Test_skip_and_return_bytes_with_reader(t *testing.T) { | ||||
| 	should.Equal(`{"a" : [{"stream": "c"}], "d": 102 }`, string(skipped)) | ||||
| } | ||||
|  | ||||
| func Test_skip_empty(t *testing.T) { | ||||
| 	should := require.New(t) | ||||
| 	should.NotNil(Get([]byte("")).LastError()) | ||||
| } | ||||
|  | ||||
| type TestResp struct { | ||||
| 	Code uint64 | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user