当前位置:网站首页>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边栏推荐
- 英特尔David Tuhy:英特尔傲腾技术成功的原因
- A picture to understand! Why did the school teach you coding but still not
- Station B boss used my world to create convolutional neural network, Lecun forwarding! Burst the liver for 6 months, playing more than one million
- Kivy tutorial of setting the size and background of the form (tutorial includes source code)
- Ssm+jsp realizes the warehouse management system, and the interface is called an elegant interface
- Comment les tests de logiciels sont - ils effectués sur le site Web? Testez la stratégie!
- Organize five stages of actual attack and defense drill
- What about the collapse of win11 playing pubg? Solution to win11 Jedi survival crash
- SQL where multiple field filtering
- AI表现越差,获得奖金越高?纽约大学博士拿出百万重金,悬赏让大模型表现差劲的任务
猜你喜欢
【线段树实战】最近的请求次数 + 区域和检索 - 数组可修改+我的日程安排表Ⅰ/Ⅲ
英特尔与信步科技共同打造机器视觉开发套件,协力推动工业智能化转型
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Have you got the same "artifact" of cross architecture development praised by various industry leaders?
acwing 843. N-queen problem
Kivy tutorial of setting the size and background of the form (tutorial includes source code)
EasyCVR集群重启导致其他服务器设备通道状态离线情况的优化
Intel and Xinbu technology jointly build a machine vision development kit to jointly promote the transformation of industrial intelligence
各路行业大佬称赞的跨架构开发“神器”,你get同款了吗?
[on automation experience] the growth path of automated testing
随机推荐
Chapter 9 Yunji datacanvas company won the highest honor of the "fifth digital finance innovation competition"!
namespace基础介绍
In depth analysis of kubebuilder
Win11玩绝地求生(PUBG)崩溃怎么办?Win11玩绝地求生崩溃解决方法
Win11控制面板快捷键 Win11打开控制面板的多种方法
深耕开发者生态,加速AI产业创新发展 英特尔携众多合作伙伴共聚
The request request is encapsulated in uni app, which is easy to understand
Introduction to namespace Basics
Win11截图键无法使用怎么办?Win11截图键无法使用的解决方法
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
leetcode 53. Maximum Subarray 最大子数组和(中等)
Win11 control panel shortcut key win11 multiple methods to open the control panel
深入解析Kubebuilder
How to solve the problem of adding RTSP device to easycvr cluster version and prompting server ID error?
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
Flex layout and usage
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Organize five stages of actual attack and defense drill
Camera calibration (I): robot hand eye calibration
Easycvr cannot be played using webrtc. How to solve it?