diff --git a/README.md b/README.md index 6ae2913..4c5eaa8 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,7 @@ The output format of the `Parse` function depends on the input type: - Slice or Array: the output is a slice of the same length as the input slice or array. Each element of the output slice is the corresponding type of the input slice or array elements, represented as strings. -- Pointer to Struct, Slice, or Map: the output is a pointer to the corresponding JSON schema-like representation. - -- Other types: the output is the type name as a string. +- Primitive types: the output is the type name as a string. ### Examples @@ -89,22 +87,8 @@ parsed := Parse(v) // "int", // } -// Pointer to Struct -v := &struct { - Age int - Name string -}{ - Age: 30, - Name: "John", -} - -parsed := Parse(v) -// parsed = *map[string]interface{}{ -// "Age": "int", -// "Name": "string", -// } -// Other types +// Primitive types v := true parsed := Parse(v) diff --git a/parser.go b/parser.go index 6a45d6c..c71c62c 100644 --- a/parser.go +++ b/parser.go @@ -19,10 +19,7 @@ const timeStringKind = "time.Time" // If the input is a map, the output will be a map with the same keys and nested types // as the input map. // -// If the input is a pointer to a struct, slice, or map, the output will be a pointer to -// the corresponding JSON schema-like representation. -// -// For other types (e.g. bool, string, int), the output will be the type name as a string. +// For primitive types (e.g. bool, string, int), the output will be the type name as a string. // // The function returns an interface{} value that can be asserted to the appropriate type // after the function call. @@ -114,11 +111,10 @@ func parseSlice(v reflect.Value) interface{} { return fmt.Sprintf("[%v]", elType) } - m := []interface{}{} + var m []interface{} for i := 0; i < v.Len(); i++ { field := v.Index(i) t := parse(field) - m = append(m, t) }