当前位置:网站首页>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边栏推荐
- Wechat can play the trumpet. Pinduoduo was found guilty of infringement. The shipment of byte VR equipment ranks second in the world. Today, more big news is here
- [team learning] [34 sessions] Alibaba cloud Tianchi online programming training camp
- How to conduct website testing of software testing? Test strategy let's go!
- 《原动力 x 云原生正发声 降本增效大讲堂》第三讲——Kubernetes 集群利用率提升实践
- 九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
- kivy教程之设置窗体大小和背景(教程含源码)
- Some understandings about 01 backpacker
- 深耕开发者生态,加速AI产业创新发展 英特尔携众多合作伙伴共聚
- Gpt-3 is a peer review online when it has been submitted for its own research
- Comment les tests de logiciels sont - ils effectués sur le site Web? Testez la stratégie!
猜你喜欢
C#使用西门子S7 协议读写PLC DB块
R language principal component PCA, factor analysis, clustering analysis of regional economy analysis of Chongqing Economic Indicators
【实践出真理】import和require的引入方式真的和网上说的一样吗
Digital chemical plant management system based on Virtual Simulation Technology
MySQL forgot how to change the password
[practice leads to truth] is the introduction of import and require really the same as what is said on the Internet
Intel David tuhy: the reason for the success of Intel aoten Technology
AI landing new question type RPA + AI =?
各路行业大佬称赞的跨架构开发“神器”,你get同款了吗?
[team learning] [34 issues] scratch (Level 2)
随机推荐
Network Security Learning - Information Collection
Win11 control panel shortcut key win11 multiple methods to open the control panel
英特尔David Tuhy:英特尔傲腾技术成功的原因
Camera calibration (I): robot hand eye calibration
Fix the problem that the highlight effect of the main menu disappears when the easycvr Video Square is clicked and played
广告归因:买量如何做价值衡量?
浙江大学周亚金:“又破又立”的顶尖安全学者,好奇心驱动的行动派
acwing 843. N-queen problem
食堂用户菜品关系系统(C语言课设)
这项15年前的「超前」技术设计,让CPU在AI推理中大放光彩
DFS和BFS概念及实践+acwing 842 排列数字(dfs) +acwing 844. 走迷宫(bfs)
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!
Win11截图键无法使用怎么办?Win11截图键无法使用的解决方法
一度辍学的数学差生,获得今年菲尔兹奖
Complimentary tickets quick grab | industry bigwigs talk about the quality and efficiency of software qecon conference is coming
Code source de la fonction [analogique numérique] MATLAB allcycles () (non disponible avant 2021a)
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
【线段树实战】最近的请求次数 + 区域和检索 - 数组可修改+我的日程安排表Ⅰ/Ⅲ
什么是Web3
Depth first traversal template principle of tree and graph