parseFieldTag parses struct field tags, handling both "js" and "json" tags This function provides unified tag parsing logic for both marshal and class reflection
(field reflect.StructField)
| 42 | // parseFieldTag parses struct field tags, handling both "js" and "json" tags |
| 43 | // This function provides unified tag parsing logic for both marshal and class reflection |
| 44 | func parseFieldTag(field reflect.StructField) FieldTagInfo { |
| 45 | // Check "js" tag first (higher priority) |
| 46 | if tag := field.Tag.Get("js"); tag != "" { |
| 47 | return parseTagString(tag, field.Name) |
| 48 | } |
| 49 | |
| 50 | // Fallback to "json" tag |
| 51 | if tag := field.Tag.Get("json"); tag != "" { |
| 52 | return parseTagString(tag, field.Name) |
| 53 | } |
| 54 | |
| 55 | // No tag found, use camelCase field name |
| 56 | return FieldTagInfo{ |
| 57 | Name: fieldNameToCamelCase(field.Name), |
| 58 | Skip: false, |
| 59 | OmitEmpty: false, |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // parseTagString parses tag string in format "name,option1,option2" |
| 64 | func parseTagString(tag, fieldName string) FieldTagInfo { |
no test coverage detected