| 123456789101112131415161718192021222324252627282930313233 | 
							- package mo
 
- import (
 
- 	"reflect"
 
- 	"testing"
 
- )
 
- func TestUnmarshalExtJSON(t *testing.T) {
 
- 	str := `{
 
-   "_id": {"$oid": "5d505646cf6d4fe581014ab2"},
 
-   "arrayField": ["hello",{"$numberInt":"10"}],
 
-   "dateField": {"$date":{"$numberLong":"1565546054692"}},
 
-   "dateBefore1970": {"$date":{"$numberLong":"-1577923200000"}},
 
-   "decimal128Field": {"$numberDecimal":"10.99"},
 
-   "documentField": {"a":"hello"},
 
-   "doubleField": {"$numberDouble":"10.5"},
 
-   "infiniteNumber": {"$numberDouble":"Infinity"},
 
-   "int32field": {"$numberInt":"10"},
 
-   "int64Field": {"$numberLong":"50"},
 
-   "minKeyField": {"$minKey":1},
 
-   "maxKeyField": {"$maxKey":1},
 
-   "regexField": {"$regularExpression":{"pattern":"^H","options":"i"}},
 
-   "timestampField": {"$timestamp":{"t":1565545664,"i":1}}
 
- }`
 
- 	var b D
 
- 	if err := UnmarshalExtJSON([]byte(str), true, &b); err != nil {
 
- 		t.Error(err)
 
- 		return
 
- 	}
 
- 	for _, e := range b {
 
- 		t.Log(e.Key, e.Value, "->", reflect.ValueOf(e.Value).Type())
 
- 	}
 
- }
 
 
  |