Skip to content

Commit

Permalink
docs: update internal documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rsfreitas committed May 17, 2023
1 parent f8ebee7 commit 732b081
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 2 additions & 6 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 732b081

Please sign in to comment.