当前位置:网站首页>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边栏推荐
- Practice Guide for interface automation testing (middle): what are the interface testing scenarios
- 軟件測試之網站測試如何進行?測試小攻略走起!
- Fix the problem that the highlight effect of the main menu disappears when the easycvr Video Square is clicked and played
- Jetson nano配置pytorch深度学习环境//待完善
- C # use Siemens S7 protocol to read and write PLC DB block
- 食堂用户菜品关系系统(C语言课设)
- 过气光刻机也不能卖给中国!美国无理施压荷兰ASML,国产芯片再遭打压
- Video fusion cloud platform easycvr video Plaza left column list style optimization
- What is Web3
- NTU notes 6422quiz review (1-3 sections)
猜你喜欢

Programmers go to work fishing, so play high-end!

用CPU方案打破内存墙?学PayPal堆傲腾扩容量,漏查欺诈交易量可降至1/30

EasyCVR视频广场点击播放时,主菜单高亮效果消失问题的修复

acwing 843. n-皇后问题

Oracle - views and sequences

In depth analysis of kubebuilder

kivy教程之设置窗体大小和背景(教程含源码)
![[team learning] [34 sessions] Alibaba cloud Tianchi online programming training camp](/img/50/bfe7229d380a514c40f9f6822381c7.jpg)
[team learning] [34 sessions] Alibaba cloud Tianchi online programming training camp

Camera calibration (I): robot hand eye calibration

What about the collapse of win11 playing pubg? Solution to win11 Jedi survival crash
随机推荐
How to solve the problem of adding RTSP device to easycvr cluster version and prompting server ID error?
Data security -- 12 -- Analysis of privacy protection
Nanopineo use development process record
未婚夫捐5亿美元给女PI,让她不用申请项目,招150位科学家,安心做科研!
Fiance donated 500million dollars to female PI, so that she didn't need to apply for projects, recruited 150 scientists, and did scientific research at ease!
Digital chemical plants realize the coexistence of advantages of high quality, low cost and fast efficiency
kivy教程之设置窗体大小和背景(教程含源码)
Zhou Yajin, a top safety scholar of Zhejiang University, is a curiosity driven activist
Case reward: Intel brings many partners to promote the innovation and development of multi domain AI industry
Acl2022 | decomposed meta learning small sample named entity recognition
树与图的深度优先遍历模版原理
How to open win11 remote desktop connection? Five methods of win11 Remote Desktop Connection
Intel David tuhy: the reason for the success of Intel aoten Technology
计数排序基础思路
acwing 843. n-皇后问题
Jetson nano配置pytorch深度学习环境//待完善
acwing 843. N-queen problem
组织实战攻防演练的5个阶段
Introduction to namespace Basics
[multi threading exercise] write a multi threading example of the producer consumer model.