javascript - How to access a JSON string's values in a React component that have been sent from a server? - TagMerge
28How to access a JSON string's values in a React component that have been sent from a server?How to access a JSON string's values in a React component that have been sent from a server?

How to access a JSON string's values in a React component that have been sent from a server?

Asked 1 years ago
1
28 answers

In react, setting state is asynchronous. so if you set state in componentDidMount and try to access it in same function, there is no guarantee that you will get value from state. But once state is set and try to get in render method you will get it.

So if you want to get the value and do another call from componentDidMount, use data from server

try something like below

componentDidMount() {        
     Code to do API call
    .then(data => {
        this.setState({user: data});
        const imgUrl = USER_IMG_URL + data.username;
        <use imgUrl>
    });
}

Source: link

0

The following example shows how you might store a simple shopping cart in JSON format:
{
  "orderID": 12345,
  "shopperName": "John Smith",
  "shopperEmail": "johnsmith@example.com",
  "contents": [
    {
      "productID": 34,
      "productName": "SuperWidget",
      "quantity": 1
    },
    {
      "productID": 56,
      "productName": "WonderWidget",
      "quantity": 3
    }
  ],
  "orderCompleted": true
}
By the way, since JSON is very closely based on the notation JavaScript uses to create arrays and objects, you can take the above JSON string and create a JavaScript object from it very easily:
<script type="text/javascript">
var cart = {
  "orderID": 12345,
  "shopperName": "John Smith",
  "shopperEmail": "johnsmith@example.com",
  "contents": [
    {
      "productID": 34,
      "productName": "SuperWidget",
      "quantity": 1
    },
    {
      "productID": 56,
      "productName": "WonderWidget",
      "quantity": 3
    }
  ],
  "orderCompleted": true
};
</script>
Here’s the previous JSON example written as XML instead:
<object>
  <property>
    <key>orderID</key>
    <number>12345</number>
  </property>
  <property>
    <key>shopperName</key>
    <string>John Smith</string>
  </property>
  <property>
    <key>shopperEmail</key>
    <string>johnsmith@example.com</string>
  </property>
  <property>
    <key>contents</key>
    <array>
      <object>
        <property>
          <key>productID</key>
          <number>34</number>
        </property>
        <property>
          <key>productName</key>
          <string>SuperWidget</string>
        </property>
        <property>
          <key>quantity</key>
          <number>1</number>
        </property>        
      </object>
      <object>
        <property>
          <key>productID</key>
          <number>56</number>
        </property>
        <property>
          <key>productName</key>
          <string>WonderWidget</string>
        </property>
        <property>
          <key>quantity</key>
          <number>3</number>
        </property> 
      </object>
    </array>
  </property>
  <property>
    <key>orderCompleted</key>
    <boolean>true</boolean>
  </property>  
</object>
JavaScript contains a built-in method, JSON.stringify(), that takes a JavaScript variable and outputs a JSON string representing the variable’s contents. For example, let’s create a JavaScript object containing our cart data from earlier, then create a JSON string from that object:
<script type="text/javascript">

var cart = {
  "orderID": 12345,
  "shopperName": "John Smith",
  "shopperEmail": "johnsmith@example.com",
  "contents": [
    {
      "productID": 34,
      "productName": "SuperWidget",
      "quantity": 1
    },
    {
      "productID": 56,
      "productName": "WonderWidget",
      "quantity": 3
    }
  ],
  "orderCompleted": true
};

alert ( JSON.stringify( cart ) ); 

</script>
This produces the output:
{"orderID":12345,"shopperName":"John Smith","shopperEmail":"johnsmith@example.com",
"contents":[{"productID":34,"productName":"SuperWidget","quantity":1},
{"productID":56,"productName":"WonderWidget","quantity":3}],
"orderCompleted":true}

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

0

My JSON
{
 "response": [
{
  "id": "0",
  "elementName": "osname",
  "isEqual": true,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "osname",
      "firstValue": "Linux\u000a",
      "secondValue": "SunOs\u000a"
    }
  ]
},
{
  "id": "1",
  "elementName": "hostname",
  "isEqual": false,
  "isPrasentinXml1": true,
  "isPrasentinXml2": true,
  "attribute": [
    {
      "name": "hostname",
      "firstValue": "estilo\u000a",
      "secondValue": "buckeye.informatica.com\u000a"
    }
  ]
}
]
}
I want to fetch Linux\u000a and SunOs\u000a, so i wrote
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
Your syntax. This works:
var jsonobj = {
    "response": [
        {
        "id": "0",
        "elementName": "osname",
        "isEqual": true,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "osname",
            "firstValue": "Linux\u000a",
            "secondValue": "Linux\u000a"}]
        },
        {
        "id": "1",
        "elementName": "hostname",
        "isEqual": false,
        "isPrasentinXml1": true,
        "isPrasentinXml2": true,
        "attribute": [{
            "name": "hostname",
            "firstValue": "estilo\u000a",
            "secondValue": "buckeye.informatica.com\u000a"}]
        }
    ]
 };

alert(jsonobj.response[0].elementName);
alert(jsonobj.response[0].attribute[0].firstValue + ", " + jsonobj.response[0].attribute[0].secondValue);

Source: link

Recent Questions on javascript

    Programming Languages