当前位置:网站首页>Can I specify a path in an attribute to map a property in my class to a child property in my JSON?
Can I specify a path in an attribute to map a property in my class to a child property in my JSON?
2022-07-07 04:46:00 【French red wine sweet】
problem :
There is some code (which I can't change) that uses Newtonsoft.Json's DeserializeObject<T>(strJSONData)
to take data from a web request and convert it to a class object (I can change the class). There are some codes ( I can't change it ) Use Newtonsoft.Json Of DeserializeObject<T>(strJSONData)
from Web Get the data in the request and convert it into a class object ( I can change the class ).By decorating my class properties with [DataMember(Name = "raw_property_name")]
I can map the raw JSON data to the correct property in my class. By using [DataMember(Name = "raw_property_name")]
Decorate my class properties , I can put the original JSON The data is mapped to the correct attributes in my class .Is there a way I can map the child property of a JSON complex object to a simple property? Is there any way to JSON The sub attributes of complex objects are mapped to simple attributes ?Here's an example: Here is an example :
{ "picture": { "id": 123456, "data": { "type": "jpg", "url": "http://www.someplace.com/mypicture.jpg" } }}
I don't care about any of the rest of the picture object except for URL, and so don't want to setup a complex object in my C# class. except URL, I don't care about any of the rest of the image object , So I don't want to be in my C# Set complex objects in class .I really just want something like: I really just want something like this :
[DataMember(Name = "picture.data.url")]public string ProfilePicture { get; set; }
Is this possible? Is that possible? ?
Solution :
Reference resources : https://stackoom.com/en/question/2Epos边栏推荐
猜你喜欢
On the 110th anniversary of Turing's birth, has the prediction of intelligent machine come true?
R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标
EasyCVR集群版本添加RTSP设备提示服务器ID错误,该如何解决?
深耕开发者生态,加速AI产业创新发展 英特尔携众多合作伙伴共聚
C # use Siemens S7 protocol to read and write PLC DB block
A detailed explanation of head pose estimation [collect good articles]
Win11玩绝地求生(PUBG)崩溃怎么办?Win11玩绝地求生崩溃解决方法
深入解析Kubebuilder
acwing 843. N-queen problem
计数排序基础思路
随机推荐
軟件測試之網站測試如何進行?測試小攻略走起!
Ssm+jsp realizes the warehouse management system, and the interface is called an elegant interface
Unit test asp Net MVC 4 Application - unit testing asp Net MVC 4 apps thoroughly
Chapter 9 Yunji datacanvas company has been ranked top 3 in China's machine learning platform market
Case reward: Intel brings many partners to promote the innovation and development of multi domain AI industry
Mathematical analysis_ Notes_ Chapter 10: integral with parameters
acwing 843. n-皇后问题
【线段树实战】最近的请求次数 + 区域和检索 - 数组可修改+我的日程安排表Ⅰ/Ⅲ
《原动力 x 云原生正发声 降本增效大讲堂》第三讲——Kubernetes 集群利用率提升实践
赠票速抢|行业大咖纵论软件的质量与效能 QECon大会来啦
mpf2_线性规划_CAPM_sharpe_Arbitrage Pricin_Inversion Gauss Jordan_Statsmodel_Pulp_pLU_Cholesky_QR_Jacobi
Win11图片打不开怎么办?Win11无法打开图片的修复方法
Depth first traversal template principle of tree and graph
Code source de la fonction [analogique numérique] MATLAB allcycles () (non disponible avant 2021a)
视频融合云平台EasyCVR视频广场左侧栏列表样式优化
Two divs are on the same line, and the two divs do not wrap "recommended collection"
树与图的深度优先遍历模版原理
Introduction to the PureMVC series
Lecture 3 of "prime mover x cloud native positive sounding, cost reduction and efficiency enhancement lecture" - kubernetes cluster utilization improvement practice
jvm是什么?jvm调优有哪些目的?