none
JSON RRS feed

  • Question

  • var json = {               

    "element": "#data-client-number='1' [data-element='FirstName']",

        "tooltip": "Please add your first name."

    }

    I have this JSON, and I want to get just the first element and read this in separate parts, first (#data-client-number='1') and ([data-element='FirstName']).

    How can I do that?

    I know, this JSON is not my idea, I just receive this from another company and I have to read this, but I want to know if there is a way to read this without using the method split().

    Thanks!

    Thursday, July 26, 2018 10:06 PM

Answers

  • Hi .Leonardo Rossetti,

    Thank you for posting here.

    Do you  want to get the value of #data-client-number and data-element or just get #data-client-number='1'  and [data-element='FirstName'].

    If you want to get the #data-client-number='1'  and [data-element='FirstName'], please try the code below.

     public static void GetValue1()
            {
                var json = "{\"element\": \"#data-client-number='1' [data-element='FirstName']\",   \"tooltip\": \"Please add your first name.\"}";
                var values = JObject.Parse(json)["element"];
            }

    Best Regards,

    Wendy


    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.

    Friday, July 27, 2018 4:36 AM
    Moderator

All replies

  • Is that on the javascript side?

    If yes, you can simply access that with json.element.


    Friday, July 27, 2018 1:41 AM
    Answerer
  • Hi .Leonardo Rossetti,

    Thank you for posting here.

    Do you  want to get the value of #data-client-number and data-element or just get #data-client-number='1'  and [data-element='FirstName'].

    If you want to get the #data-client-number='1'  and [data-element='FirstName'], please try the code below.

     public static void GetValue1()
            {
                var json = "{\"element\": \"#data-client-number='1' [data-element='FirstName']\",   \"tooltip\": \"Please add your first name.\"}";
                var values = JObject.Parse(json)["element"];
            }

    Best Regards,

    Wendy


    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.

    Friday, July 27, 2018 4:36 AM
    Moderator