DataContract with Json.Net
2024-09-27 00:20:04
https://www.newtonsoft.com/json/help/html/DataContractAndDataMember.htm
如果class使用了DataContract,name没有使用DataMember的property就不解析
[DataContract]
public class File
{
// excluded from serialization
// does not have DataMemberAttribute
public Guid Id { get; set; } [DataMember]
public string Name { get; set; } [DataMember]
public int Size { get; set; }
} File file = new File
{
Id = Guid.NewGuid(),
Name = "ImportantLegalDocuments.docx",
Size = *
}; string json = JsonConvert.SerializeObject(file, Formatting.Indented); Console.WriteLine(json);
// {
// "Name": "ImportantLegalDocuments.docx",
// "Size": 51200
// }
最新文章
- MFC下打开选择文件夹并获取文件夹的绝对路径
- puppet安装
- Python面试里面的那些问题
- UI3_CustomUITableViewCell
- 使用JavaScript检测浏览器
- HTTP协议(三)
- hive -- 协同过滤sql语句
- database锁实现
- MFC为多个控件绑定同一个函数
- Python模拟微博登陆,亲测有效
- spring邮件发送
- centos7搭建mysql5.7主从同步
- Python 优雅获取本机 IP 方法
- js文件流下载通用方法
- 转载:mysql binlog同步redis
- mysql允许远程登录
- Git 同步远程仓库
- Android 通过触摸动态地在屏幕上画矩形
- homebrew命令
- 安装VS2010 SP1后,再安装mvc3