在DeserializeObject之前替换Json属性名称 [英] Json property name replace before DeserializeObject
问题描述
HI全部,
以下是我收到的示例JSON。
实际上,我们的JSON类是使用包含的属性定义的' - ',而传入的JSON包含'_'。
现在我需要用' - '替换传入的JSON字符串'_'。
{
" user_Name":" 66666",
" password":" test1234",
" customers_List":[
{
" address_to":" Test Stree2",
" customer_Number":" US01-000281",
" city_name":""
}
]
}
我可以使用字符串替换来做到这一点,这是不正确的。
我也通过传递JSONSETTINGS来尝试这个,它取代了相应的属性名称(这可能会消耗时间)。
请建议我一个简单的解决方案足以将'_'替换为' - '。
迫切需要< g class =" gr_ gr_24 gr-alert gr_gramm gr_inline_cards gr_run_anim标点符号仅用于替换为"数据-gr-id ="24" id =" 24">请< / g>
< blockquote>
您是否考虑过简单调整你的课程而不是改变字符串?
HI All,
Below is the sample JSON I receive.
Actually, our JSON class is defined with the properties containing '-', whereas the incoming JSON contains '_'.
Now I need to replace the incoming JSON string '_' with '-'.
{
"user_Name": "66666",
"password": "test1234",
"customers_List": [
{
"address_to": "Test Stree2",
"customer_Number": "US01-000281",
"city_name": ""
}
]
}
I can do that using string replace, which is incorrect.
I also tried this by passing JSONSETTINGS, which replaces the appropriate attribute names( this might consume time).
Please suggest me a solution which should be simple enough to just replace incoming '_' with '-'.
Needed urgently <g class="gr_ gr_24 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" data-gr-id="24" id="24">please</g>
Did you consider to simply adjust your classes instead of changing the string?
这篇关于在DeserializeObject之前替换Json属性名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!