mirror of https://github.com/goccy/go-json.git
Merge 3aaec8ddc2
into 3e9769d637
This commit is contained in:
commit
4dc3437861
|
@ -318,7 +318,11 @@ func typeToStructTags(typ *runtime.Type) runtime.StructTags {
|
|||
if runtime.IsIgnoredStructField(field) {
|
||||
continue
|
||||
}
|
||||
tags = append(tags, runtime.StructTagFromField(field))
|
||||
structTag := runtime.StructTagFromField(field)
|
||||
if structTag.IsReadonly {
|
||||
continue
|
||||
}
|
||||
tags = append(tags, structTag)
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
|
|
@ -813,7 +813,11 @@ func (c *Compiler) typeToStructTags(typ *runtime.Type) runtime.StructTags {
|
|||
if runtime.IsIgnoredStructField(field) {
|
||||
continue
|
||||
}
|
||||
tags = append(tags, runtime.StructTagFromField(field))
|
||||
structTag := runtime.StructTagFromField(field)
|
||||
if structTag.IsWriteonly {
|
||||
continue
|
||||
}
|
||||
tags = append(tags, structTag)
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ type StructTag struct {
|
|||
IsTaggedKey bool
|
||||
IsOmitEmpty bool
|
||||
IsString bool
|
||||
IsWriteonly bool
|
||||
IsReadonly bool
|
||||
Field reflect.StructField
|
||||
}
|
||||
|
||||
|
@ -82,6 +84,10 @@ func StructTagFromField(field reflect.StructField) *StructTag {
|
|||
switch opt {
|
||||
case "omitempty":
|
||||
st.IsOmitEmpty = true
|
||||
case "readOnly":
|
||||
st.IsReadonly = true
|
||||
case "writeOnly":
|
||||
st.IsWriteonly = true
|
||||
case "string":
|
||||
st.IsString = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue