当前位置:网站首页>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边栏推荐
- This "advanced" technology design 15 years ago makes CPU shine in AI reasoning
- Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
- What work items do programmers hate most in their daily work?
- 计数排序基础思路
- Win11截图键无法使用怎么办?Win11截图键无法使用的解决方法
- Some understandings about 01 backpacker
- 图灵诞辰110周年,智能机器预言成真了吗?
- DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
- sscanf,sscanf_s及其相关使用方法「建议收藏」
- Windows are not cheap things
猜你喜欢

What about the collapse of win11 playing pubg? Solution to win11 Jedi survival crash

Win11玩绝地求生(PUBG)崩溃怎么办?Win11玩绝地求生崩溃解决方法

英特尔David Tuhy:英特尔傲腾技术成功的原因

Mathematical analysis_ Notes_ Chapter 10: integral with parameters

Depth first traversal template principle of tree and graph

EasyCVR无法使用WebRTC进行播放,该如何解决?

AI 落地新题型 RPA + AI =?

acwing 843. n-皇后问题

R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标

Deeply cultivate the developer ecosystem, accelerate the innovation and development of AI industry, and Intel brings many partners together
随机推荐
leetcode 53. Maximum Subarray 最大子数组和(中等)
Unit test asp Net MVC 4 Application - unit testing asp Net MVC 4 apps thoroughly
视频融合云平台EasyCVR视频广场左侧栏列表样式优化
Oracle -- 视图与序列
SQL where multiple field filtering
Easycvr cannot be played using webrtc. How to solve it?
Digital chemical plants realize the coexistence of advantages of high quality, low cost and fast efficiency
每人每年最高500万经费!选人不选项目,专注基础科研,科学家主导腾讯出资的「新基石」启动申报
Poor math students who once dropped out of school won the fields award this year
Complimentary tickets quick grab | industry bigwigs talk about the quality and efficiency of software qecon conference is coming
一图看懂!为什么学校教了你Coding但还是不会的原因...
Chapter 9 Yunji datacanvas company won the highest honor of the "fifth digital finance innovation competition"!
How to solve the problem of adding RTSP device to easycvr cluster version and prompting server ID error?
leetcode 53. Maximum subarray maximum subarray sum (medium)
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Flex layout and usage
深耕开发者生态,加速AI产业创新发展 英特尔携众多合作伙伴共聚
Up to 5million per person per year! Choose people instead of projects, focus on basic scientific research, and scientists dominate the "new cornerstone" funded by Tencent to start the application
R language principal component PCA, factor analysis, clustering analysis of regional economy analysis of Chongqing Economic Indicators
Depth first traversal template principle of tree and graph