【发布时间】:2019-09-05 18:23:47
【问题描述】:
我们有类似 Golang 的 json 注解的东西吗?
type FieldType struct {
TypeName string `json:"typeName"`
CodeType string `json:"codeType"`
Suffix string `json:"suffix"`
PropertiesRaw json.RawMessage `json:"properties"`
Properties FieldTypePropertyMap
}
我有一个 json 字符串:
{ "long_name":"dffdf" }
我的班级:
public class Result
{
public int LongName {get; set;}
}
由于有下划线,LongName 始终为空,我不想在我的类属性中使用下划线。
反序列化时是否有忽略下划线的选项?
【问题讨论】:
-
或者您可以按.NET NewtonSoft JSON deserialize map to a different property name 中所示的每个属性执行此操作。
-
谢谢@dbc 是的,我只是在寻找类似 :json 忽略下划线的东西。这就是为什么我没有找到这些问题。感谢您的帮助:)