Parsing a JSON object with Special characters in property key

后端 未结 1 1125
自闭症患者
自闭症患者 2021-01-16 02:41

I have a JSON file that looks something like this

{
    \"samlp:Response\": {
        \"@attributes\": {
            \"xmlns:samlp\": \"urn:oasis:names:tc:SA         


        
相关标签:
1条回答
  • 2021-01-16 03:45

    Take a look at Property Accessors. Consider the following:

    const jsonObject = {
      "samlp:Response": {
        "@attributes": {
          "xmlns:samlp": "urn:oasis:names:tc:SAML:2.0:protocol",
          "ID": "_482d7b9c-3e50-47cb-aa64-4e3655352c64",
          "Version": "2.0",
          "IssueInstant": "2019-06-27T17:02:47.711Z",
          "Destination": "https://jjds-sunrise--cqsupport--c.cs102.visual.force.com/apex/ResponseReceiver",
          "InResponseTo": "Azure_9849028456"
        }
      }
    };
    
    
    console.log(jsonObject["samlp:Response"]["@attributes"].ID);

    0 讨论(0)
提交回复
热议问题