Json property name replace before DeserializeObject RRS feed

  • Question

  • 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>

    • Edited by sandydv85 Tuesday, December 4, 2018 3:27 AM
    Tuesday, December 4, 2018 3:27 AM

All replies

  • Did you consider to simply adjust your classes instead of changing the string?

    Tuesday, December 4, 2018 7:12 AM
  • Hi sandydv85,

    Thank you for posting here.

    For your question, you want to replace the incoming JSON string '_' with '-'.

    I think string replacement is ok.

    >> which is incorrect.

    I don't know where this error happened. Can you provide more information about this error?

    Best regards,

    Jack J Jun.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 5, 2018 10:04 AM