【问题标题】:how to convert key value from result to uppercase api net core 3.1?how to convert key value from result to uppercase api net core 3.1?
【发布时间】:2022-12-26 22:20:46
【问题描述】:

model

        public string NS_ID { set; get; }
        public string TONV_ABC { set; get; }
        public string NAME_ABC { set; get; }
        public string MAABC { set; get; }

result json when test postman

        "nS_ID": "",
        "tonV_ABC": "",
        "namE_ABC": "",
        "maabc": "F02",

result I want

        "NS_ID": "",
        "TONV_ABC": "",
        "NAME_ABC": "",
        "MAABC": "F02",

please help me

i try convert but not working , please help me

【问题讨论】:

  • didn't get you, can you explain more
  • I want to keep the names of the fields in the model in the json return result when call api

标签: c# json .net api


【解决方案1】:

you can try to deserialize the JSON string to a Dictionary<string, object>. then create another Dictionary. iterate over the first dictionary and add all the key-value pairs to the new dictionary why making the key to upper case using the ToUpper() method. then serialize the new dictionary to the JSON string.

【讨论】:

    猜你喜欢
    • 2022-12-28
    • 2022-12-01
    • 2022-12-02
    • 1970-01-01
    • 2022-12-02
    • 2022-12-16
    • 2022-12-02
    • 2022-12-26
    • 2022-12-28
    相关资源
    最近更新 更多